htaccess的忽略目录及其子目录 [英] htaccess Ignoring directory and its subdirectories
问题描述
我在我的htaccess文件如下:
I have the following in my htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(mailinglist)/.*$ - [L]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
我基本上要击中最后一行删除htaccess的,如果我在邮件列表目录。
I basically want to remove htaccess from hitting that last line if I am in the mailinglist directory.
这仅适用于在/邮件列表目录的根目录的项目。有一次,我去喜欢更深/邮件列表/ W / 1它打破,命中去年重写规则。如何从过去的重写规则,如果我在/邮件列表目录的处理停止。
This only works for items in the root of the /mailinglist directory. Once I go deeper like /mailinglist/w/1 it breaks and hits that last rewrite rule. How do I stop it from processing that last rewrite rule if I am in the /mailinglist directory.
原因是我有一组不同的htaccess在该目录中,我不希望这样的htaccess来控制它。
The reason is I have a different set of htaccess in that directory and I do not want this htaccess to control it.
推荐答案
都被应用到了错误的规则的情况下,你需要更换在你的规则:
The conditions are being applied to the wrong rule, You need to swap around your rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(mailinglist)/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
条件只适用于紧随其后的规则,所以2 ! - ˚F
和 - D!
条件被误用的直通,而的index.php
规则缺失的情况。
Conditions only apply to the immediately following rule, so the 2 !-f
and !-d
conditions are being misapplied to the passthrough, while the index.php
rule is missing those conditions.
这篇关于htaccess的忽略目录及其子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!