开发者

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜