I have an .htaccess
file like this:
我有一个像这样的.htaccess文件:
RewriteCond /question2answer/%{REQUEST_FILENAME} !-f
RewriteCond /question2answer/%{REQUEST_FILENAME} !-d
RewriteCond OTHER_CONDITION_1
RewriteRule RULE_1 [L]
RewriteCond /question2answer/%{REQUEST_FILENAME} !-f
RewriteCond /question2answer/%{REQUEST_FILENAME} !-d
RewriteCond OTHER_CONDITION_2
RewriteRule RULE_2 [L]
...
De Morgan's laws tells me there is a better way to do this:
德摩根的法律告诉我有更好的方法来做到这一点:
RewriteCond /question2answer/%{REQUEST_FILENAME} -f
RewriteRule NO-OP [L]
RewriteCond /question2answer/%{REQUEST_FILENAME} -d
RewriteRule NO-OP [L]
RewriteCond OTHER_CONDITION_1
RewriteRule RULE_1 [L]
RewriteCond OTHER_CONDITION_2
RewriteRule RULE_2 [L]
...
What is the no-op rule that I can use here? And if there are many, I am seeing the one with the least performance impact.
我可以在这里使用的无操作规则是什么?如果有很多,我会看到性能影响最小的那个。
1 个解决方案
#1
5
NO_OP (no operation) rule can be this:
NO_OP(无操作)规则可以是这样的:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
Which means if request is for a file OR if request is for a directory then don't do anything (denoted by -
in target URI).
这意味着,如果请求是针对文件,或者如果请求是针对目录,则不执行任何操作(在目标URI中表示为 - )。
#1
5
NO_OP (no operation) rule can be this:
NO_OP(无操作)规则可以是这样的:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
Which means if request is for a file OR if request is for a directory then don't do anything (denoted by -
in target URI).
这意味着,如果请求是针对文件,或者如果请求是针对目录,则不执行任何操作(在目标URI中表示为 - )。