我有一个htaccess设置 已经 重写对index.php的所有请求。但现在我有一个条件,我想重写(我不知道该怎么做或选择哪个)一个子文件夹/管理员到index.php?route = admin / login ,是的确切的网址
的期望 的
www.domain.com/admin
重写
www.domain.com/index.php?route=admin/login
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/install(.*)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
#########################################
##I expect the line below will go to the url , but when i enter the subfolder , the page remain at the index
RewriteRule ^admin/(.*)$ /$1?route=admin/login [R=301,L]
答案 0 :(得分:1)
尝试将其放入/admin/.htaccess
:
RewriteEngine On
RewriteBase /admin/
RewriteRule ^$ /index.php?route=admin/login [R=301,QSA,L]
答案 1 :(得分:0)
从www.domain.com/admin重写管理员登录
RewriteRule ^admin$ /index.php?route=admin/login [R=301,L]
重写其他请求,例如:
www.domain.com/admin/list_users
www.domain.com/admin/send_mail
等
RewriteRule ^admin/(.*)$ /index.php?route=admin/$1 [R=301,L]
UPD。
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/install(.*)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [L]
#########################################
##I expect the line below will go to the url , but when i enter the subfolder , the page remain at the index
#RewriteRule ^admin/(.*)$ /$1?route=admin/login [R=301,L]
从PHP文件改为$ _GET ['route']使用$ _SERVER ['REQUEST_URI']
OR UPD domain.com/admin/login
RewriteEngine On
RewriteRule ^admin/(.*)$ /index.php?route=admin/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/install(.*)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [L]
#########################################