...

View Full Version : RewriteRule with 2 variables



mitch_h
01-17-2011, 10:52 AM
This is the code I have in my .htaccess.


Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^ - [L]
RewriteRule ^([^/]+),([^/]+)$ index.php?id=$1&mode=$2 [NC,L]

The last line is the important one for the problem I am having. It means I can have a url:
www.domain.com/home,all
which is the same as:
www.domain.com/?id=home&mode=all

It works great when the url has ".com/something,something" even ".com/home,s" or "home,1". The problem occurs when I just have ".com/home" or ".com/home,".

Does anyone know how I can have it work with either id=$1 alone or with &mode=$2.

Thanks.

abduraooft
01-18-2011, 08:25 AM
Try

RewriteRule ^([^/]+),?([^/]+)?$ index.php?id=$1&mode=$2 [NC,L]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum