htaccess: Rewrite collision - simple question
This row will certainly cause a littl开发者_如何学Ce collision as it will try to rewrite the goal itself:
RewriteRule ^/(.*)$ page.php?q=$1 [L,NC]
Now, how do I prevent this?
Just add a condition that the matched string is not the same as the destination:
RewriteCond $1 !=page.php
RewriteRule ^/(.*)$ page.php?q=$1 [L]
Here the !=
in RewriteCond
indicates a negated lexicographic comparison instead of the implied regular expression comparison.
Using a conditional Rewrite:
RewriteCond %{REQUEST_URI} !^page.php?
RewriteRule ^/(.*)$ page.php?q=$1 [L,NC]
精彩评论