[英]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.