困扰多年的THINKPHP隐藏后台.php问题终于解决了!

前台隐藏index.php很简单. 官方就是api说明文档就有.htaccess的规则.  



                       RewriteEngine on
                       RewriteCond %{REQUEST_FILENAME} !-d
                       RewriteCond %{REQUEST_FILENAME} !-f
                       RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]


上面是隐藏index.php的规则 ,  要是想隐藏admin.php后台入口的, 要加上下面这几行

RewriteRule admin$ ./admin.php [NC,L]
RewriteRule admin/$ ./admin.php [NC,L]
RewriteRule admin/(.*)$ admin.php/$1 [NC,QSA,PT,L]


最后变成这样:


                       RewriteEngine on
                       RewriteCond %{REQUEST_FILENAME} !-d
                       RewriteCond %{REQUEST_FILENAME} !-f
                       RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

                       RewriteRule admin$ ./admin.php [NC,L]
                      RewriteRule admin/$ ./admin.php [NC,L]
                      RewriteRule admin/(.*)$ admin.php/$1 [NC,QSA,PT,L]

你可能感兴趣的:(thinkphp)