繁体   English   中英

从特定的子文件夹重写htaccess

[英]Rewrite htaccess from specific subfolder

我有一个htaccess设置,它已经将所有请求重写为index.php。 但是现在我处于一种情况,我想重写(我不确定该怎么做或选择哪个) 子文件夹/ admin到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]

尝试将其放在/admin/.htaccess

RewriteEngine On
RewriteBase /admin/

RewriteRule ^$ /index.php?route=admin/login [R=301,QSA,L]

从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']

或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]
#########################################

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM