我有一个htaccess代码如下所示:
RewriteEngine On
RewriteCond $1 !^/administrator
RewriteCond %{HTTP_HOST} ^localhost/host
RewriteRule (.*) http://localhost/host/$1 [R=301,L]
RewriteRule ^([-\w]+)?/?([-\w]+)?/?([-\w]+)?/?$ index.php?seg1=$1&seg2=$2&seg3=$3
但它仍然读取administrator
文件夹中的htaccess。代码不正确吗?
感谢。
答案 0 :(得分:1)
RewriteCond
语句仅适用于一个 RewriteRule
。
您需要为第二次重写规则重复RewriteCond
(并使用REQUEST_URI
):
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/administrator
RewriteCond %{HTTP_HOST} ^localhost/host
RewriteRule (.*) http://localhost/host/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/administrator
RewriteCond %{HTTP_HOST} ^localhost/host
RewriteRule ^([-\w]+)?/?([-\w]+)?/?([-\w]+)?/?$ index.php?seg1=$1&seg2=$2&seg3=$3