Apache 如何避免重写特定目录的规则?
这是我当前的Apache 如何避免重写特定目录的规则?,apache,.htaccess,Apache,.htaccess,这是我当前的.htaccess数据 # permalinks RewriteEngine on # users RewriteRule ^([a-z0-9_-]{2,15})$ /user.php?username=$1 [QSA,L] 这显然意味着 http://testsite.net/asantos 解析为: http://testsite.net/user.php?username=asantos 该网站在根目录中还有一个inc目录,如果我打开此url http://testsi
.htaccess
数据
# permalinks
RewriteEngine on
# users
RewriteRule ^([a-z0-9_-]{2,15})$ /user.php?username=$1 [QSA,L]
这显然意味着
http://testsite.net/asantos
解析为:
http://testsite.net/user.php?username=asantos
该网站在根目录中还有一个inc目录,如果我打开此url
http://testsite.net/inc/
它实际上重定向到:
http://testsite.net/inc/?username=inc
对于位于网站根目录中的现有目录,如何避免这种行为
对于位于网站根目录中的现有目录,如何避免这种行为
使用:
我是否必须在每个
重写规则
之前指定那些重写条件
条件?请参阅我的更新答案,现在您不需要对该跳过规则下面的所有规则重复这些条件。还有一种情况,如果我使用testsite.net/inc,它就不起作用了-只有当我使用testsite.net/inc/它也应该适用于/inc
时,它才起作用。我已经对此进行了测试,它适用于带斜杠或不带斜杠的目录。确保没有directorysash Off
目录。(或者在此.htaccess顶部添加目录斜杠)
# permalinks
RewriteEngine on
# skip all files and directories from rewrite rules *below*
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([a-z0-9_-]{2,15})$ /user.php?username=$1 [QSA,L]
# more rules here