开发者

htaccess: Rewrite collision - simple question

开发者 https://www.devze.com 2023-01-13 21:03 出处:网络
This row will certainly cause a littl开发者_如何学Ce collision as it will try to rewrite the goal itself:

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

精彩评论

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

关注公众号