Generally, when we write the front desk is home and the background is admin
Then our backend is domain name/admin, so it is very troublesome for us to modify this address at any time
At first you may think of changing the module names or grouping them (version 3.1)
In this case, not only do you have to change the configuration, but you also have to change a name on all the controls, which is too troublesome
Next, we use routing rules to prohibit admin access//1. First, we let the judgment not be made during login without bouncing (the code can be like this)<br>
if(!session("?id")){<br>
exit("I want to rebel!");<br>
//header("Location: ".U('Login/index')); Never jump<br>
}<br>
<br>
//2, we prohibit requests such as admin/* and write the following code in the configuration<br>
<br>
<br>
'URL_ROUTER_ON' => true, // Turn on routing<br>
'URL_ROUTE_RULES' =>array( <br>
'admin/$' => 'Admin/Index/index',<br>
//Ban it. The principle is to point him to a non-login address. If he is not logged in, exit("I want to rebel!");<br> will be displayed.
'admin/login$' => 'Admin/Index/index', //Disable it,<br>
'admin/login/index' => 'Admin/Index/index', //Disable it,<br>
//Of course you can also use regular expressions to write here<br>
),<br>
<br>
//3, add the address we can access, (I wrote it separately here, you can also merge it with the above code)<br>
'URL_ROUTE_RULES' =>array(<br>
'/(admin123|admin456)/i' => 'Admin/Login/index', //Accessible<br>
///(admin123)/i brackets Write multiple uses that can be accessed | separated i as not distinguished and lowercase
),<br>
<br>
//4, you can make a background setting and save a separate rule in the configuration file<br>
<br>
<br><img src="/Uploads/editor/2016-07-25/57957d1b798f1.png" alt="Use routing to modify the backend address developed by thinkphp framework" >
<br>
//5, final effect<br>
<br>
<br><img src="/Uploads/editor/2016-07-25/57957d4f2db60.png" alt="Use routing to modify the backend address developed by thinkphp framework" >
<br>
<br>
//For more useful codes, please contact us<br>
//Forum www.flash127.com<br>
//QQ group 324098841<br>
//Mengxue Forum->> Dreams are here, let dreamers gather together to work hard and fight for their dreams! <br>