我有这样的htaccess:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ index.php?p=$1&id=$2 [NC,L] # Handle product requests
RewriteRule ^([a-zA-Z0-9-]+)/?$ index.php?p=$1 [NC,L] # Handle product requests
RewriteRule ^admin/$ admin/index.php [NC,L] # Handle product requests
RewriteRule ^$ index.php?p=index [NC,L] # Handle product requests
但无论何时我输入:http://site-my.com/admin/
我都不明白我想在文件夹admin中调用index.php
。
有人能帮助我吗?
感谢。
答案 0 :(得分:1)
将管理员重写规则置于正则表达式规则之上:
RewriteEngine On
RewriteRule ^admin/$ admin/index.php [NC,L] # Handle product requests
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ index.php?p=$1&id=$2 [NC,L] # Handle product requests
RewriteRule ^([a-zA-Z0-9-]+)/?$ index.php?p=$1 [NC,L] # Handle product requests
RewriteRule ^$ index.php?p=index [NC,L] # Handle product requests
否则你的正则表达式(特别是原始订单中的第二个)会占用管理员,而你的第三条规则永远不会被应用。