Forum Moderators: phranque

Message Too Old, No Replies

two rewrite rules conflict with each other

         

phparion

8:19 am on Apr 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi

Please look at the following two rules,

RewriteRule ^([^/]+)/reviews.html(.*)$ /reviews.php?prof=$1&anc=$2 [L]

RewriteCond %{REQUEST_URI} !^/keys/.*$
RewriteRule ^([^.]+)/$ /show_pages.php?main_cat_name=$1&mode=maincatindex [L]

When i disable the second rule the first rules works fine however as soon as I enable it, the first rule is not matched anymore and the second rule is executed despite the fact that the second rule comes after first.

I am lost how to solve this. please help

jdMorgan

1:35 pm on Apr 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The likely problem is that your patterns are not sufficiently specific to the two "kinds" of URLs they are intended to rewrite. The first rule may be sufficiently specific, but the second will rewrite any URL that does not contain a period and ends with a slash. It is also likely that another rule (or rules) is involved.

Also, be aware that mod_rewrite in .htaccess is recursive; If any rule is executed, then mod_rewrite processing re-starts, in order to see if the new URL has rules that apply to it (for example, access control rules). This happens whether or not you use the [L] flag on rules.

Please describe the purpose of these two rules, and the URL-formats they are intended to rewrite.

What do you actually want these rules to do?

Jim

phparion

5:30 pm on Apr 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Annoyingly enough it started to work after thirty minutes. I had cleared cache but still was facing problem. But it was fixed itself. I have no idea what happened :-s both rules are working now without any conflict.

g1smd

1:07 am on Apr 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Check carefully, using both valid and non-valid URLs, to be really sure.