I have an .htaccess
file like this:
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.
NO_OP (no operation) rule can be this:
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With