这是文件树:
我在.htaccess中有这两条规则,它位于/
中RewriteRule ^somedir$ /somefile.php [L]
RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L]
因此...
当/ dir /存在时,我需要添加一个不添加cat = $ 1的规则。
答案 0 :(得分:2)
只需在第二条规则之前添加RewriteCond
即可。基本上,如果以product
:
RewriteRule ^somedir$ /somefile.php [L]
RewriteCond %{REQUEST_URI} !^/product [NC]
RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L]
要防止重定向真实文件或目录,请在规则之前添加以下两行:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d