Rewrite URL with variables set to specific values

Discuss practical ways rearrange URLs using mod_rewrite.

Rewrite URL with variables set to specific values

Postby Guest » Fri May 14, 2004 12:27 am

Hello,
I need to be able to rewrite someth like
www.mysite.co.uk/search.php?type=PO&minprice=500
to
www.mysite.co.uk/products/family-holiday/

Thanks in advance!
Guest
 

Postby stuarta » Fri May 14, 2004 2:17 am

Oops that was me... not guest!
stuarta
 
Posts: 6
Joined: Fri May 14, 2004 12:21 am

Postby seomike » Fri May 14, 2004 8:46 am



RewriteEngine On
RewriteBase /
RewriteRule ^products/family-holiday/$ /search.php?type=PO&minprice=500
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas

Postby stuarta » Mon May 17, 2004 12:19 am

Thanks, what I really need is to go the other way though, I have your rule;

RewriteRule ^products/family-holiday/$ /search.php?type=PO&minprice=500

but I need to put one before it, so that if some one explicitly goes to
/search.php?type=PO&minprice=500 it rewrites to
^products/family-holiday/$
chaining onto the next rule.

If it's not possible to do this without causing an infinate loop then I'll have to do this redirect in php I think... but then it must be possible, but the regex eludes me...
stuarta
 
Posts: 6
Joined: Fri May 14, 2004 12:21 am

Postby stuarta » Mon May 17, 2004 2:59 am

Oh and I forgot to mention, I need to check for parameters being those specific values; not just catch search.php as I need another redirect where
MINPRICE is set to someth else.
stuarta
 
Posts: 6
Joined: Fri May 14, 2004 12:21 am

Postby seomike » Mon May 17, 2004 4:45 am

then you would have to implement your price into the mod

RewriteRule ^products/family-holiday/(.*)/$ /search.php?type=PO&minprice=$1

so make your url products/family-holiday/500/
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas

Postby stuarta » Mon May 17, 2004 7:27 am

Cool thanks... I'm nearly there....

Is there any way to do it in reverse tho, I really need a rule so that stuff coming to /search.php goes to /products/family-holiday, then I can apply my other rules later, just can't find anything anywhere about doing it this (backwards) way round....

I need some kind of working equivilent of
RewriteRule /search.php?type=PO&minprice=$1 ^products/family-holiday/(.*)/$

(Which doesn't work as my knowledge of regexes isn't quite there yet)....
stuarta
 
Posts: 6
Joined: Fri May 14, 2004 12:21 am

Thanks for all the fish...

Postby stuarta » Mon May 17, 2004 8:20 am

Thanks for the help, in the end I used mod rewrite for the normal redirects, and the backwards ones I needed to do (see previous posts), I wrote something in php to redirect from urls including parameters, this way was much easier in the end!
stuarta
 
Posts: 6
Joined: Fri May 14, 2004 12:21 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 14 guests

cron