Hello, Im relatively new to using mod_rewrite and regular expressions as well. I am SEOing my links and using the following rewrite rule: RewriteRule ^.*_deal([0-9]+)(_more.*)?$ pddetail.php?id=$1&page=$2 [NC,L] The thing is though, the page parameter ($2) is optional, so if the URL coming in doesnt have this variable: (_more.*), I dont want the page parameter to exist. With the above rule, if (_more.*) is empty, it just passes an empty page parameter. Any ideas on how I can avoid this and not pass the page parameter if (_more.*) is empty? Thanks. zibinet
Add a rule above that one which applies to only the first variable existing, the [L]ast flag on this new rule will stop the one you have there from being processed if _more doesn't exist. RewriteRule ^.*_deal([0-9]+)$ pddetail.php?id=$1 [NC,L] RewriteRule ^.*_deal([0-9]+)_more(.*)$ pddetail.php?id=$1&page=$2 [NC,L] Code (markup):