Rewrite 2 rules problem...

New to mod_rewrite? This is a good place to start.

Rewrite 2 rules problem...

Postby wwfc_barmy_army » Sat Aug 15, 2009 12:27 am

Hello,

I have this rule at the moment:
Code: Select all
Options +FollowSymLinks
RewriteEngine on

RewriteRule ^(.*)$ index.php?id=$1 [QSA]
RewriteRule ^(.*)/(.*)/(.*)$ index.php?id=$1&width=$2&height=$3 [L,QSA]


This is what happens with the following:
mydomain.com/1/200/300 - Doest exactly what I want
mydomain.com/1/ - Goes off it some wild loop of kind of a mixture of both

Any ideas how i can get around this? I want 2 different rules depending on the url.

Thanks for any help.
wwfc_barmy_army
 
Posts: 7
Joined: Fri Aug 14, 2009 5:32 am

Postby richardk » Sun Aug 16, 2009 7:12 am

The first rule matches the request to /index.php?id=1.

Try
Code: Select all
Options +FollowSymLinks
RewriteEngine on

RewriteRule ^([0-9]+)/?$ /index.php?id=$1 [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/?$ /index.php?id=$1&width=$2&height=$3 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 32 guests

cron