从特定子文件夹重写htaccess


Rewrite htaccess from specific subfolder

我有一个htaccess设置,已经将所有请求重写到index.php。但现在我遇到了一个条件,我想重写(我不知道如何做或选择哪个)子文件夹/admin到index.php?route=admin/login,是的,带有确切的url

预期

www.domain.com/admin

重写到

www.domain.com/index.php?route=管理员/登录

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]

AND从php文件改为$_GET['route']使用$_SERVER['REQUEST_URI']

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