views:

21

answers:

1
+2  Q: 

RewriteRule help

I have successfully setup htaccess to do this:

   domain.com/ad.php?ad_id=bmw_m3_2498224

INTO:

   domain.com/ads/bmw_m3_2498224

However, I have a link on the page which makes the page submit to itself... The link saves the ad inside a cookie:

   domain.com/ad.php?ad_id=bmw_m3_2498224&save=1 // Note the 'save' variable

I need to make this work on the rewritten rule also, so this link:

  domain.com/ads/bmw_m3_2498224/save

will save the cookie...

I have this so far which DOES NOT work for the save part:

  RewriteRule ^annons/([a-zA-Z0-9_]+)$ ad.php?ad_id=$1 [NC,L]

How can I include another rule to accomplish what I want?

Thanks

+1  A: 

A simple way would be to add this line above what you currently have:

RewriteRule ^annons/([a-zA-Z0-9_]+)/save$ ad.php?ad_id=$1&save=1 [NC,L] RewriteRule ^annons/([a-zA-Z0-9_]+)$ ad.php?ad_id=$1 [NC,L]

This should get triggered before the general rule is and work just the same.

Marco Ceppi
But what if save isn't set then? Will it still work?
Camran
Marco Ceppi