Forum Moderators: phranque

Message Too Old, No Replies

Conflict in rule please help

         

varunkrish

6:26 pm on Dec 14, 2005 (gmt 0)

10+ Year Member



Options -Indexes
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^wallpapers\-(.*)\-index\.html$ wallpapers.php?category=$1 [nc]

RewriteRule ^wallpapers\-(.*)\-(.*)\-index\.html$ wallpapers.php?category=$1&folder=$2 [nc]

there is a conflict between rules 1 and 2 . i cant figure it out

please help.

if i remove rule1 rule2 works fine or else rule1 catches both rule1 and rule2 :(

jd01

7:25 pm on Dec 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is .* catches EVERYTHING, so you are catching both parameters with the first rule. I suggest [^-]+ instead, this way you will 'catch' both parameters individually.

RewriteRule ^wallpapers\-([^-]+)\-index\.html$ wallpapers.php?category=$1 [L,NC]
RewriteRule ^wallpapers\-([^-]+)\-([^-]+)\-index\.html$ wallpapers.php?category=$1&folder=$2 [L,NC]

Hope this helps.

Justin

varunkrish

6:00 am on Dec 15, 2005 (gmt 0)

10+ Year Member



is it a must to have longer rules on the top and shorter ones below it

jd01

11:08 am on Dec 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No... you actually want to write your rules so they are as independent as possible, so you can order them with the most accessed resources first.

If you are having to adjust your order based on your rules, you are usually matching too many patterns. (Unless you are planning match everything with a single rule at some point. EG using a 'catch-all' at the end of your ruleset)

Justin