Mod rewrite with multiple query strings
I'm a complete n00b when it comes to regular expressions. I need these redirects:
(1)
www.mysite.com/bike.php?id=001&product=Product-Name&source=Source-Name
should become -> www.mysite.com/Source-Name/001-Product-Name
(2)
www.mysite.com/car.php?id=002&product=Product-Name&source=Source-Name
should become -> www.mys开发者_Python百科ite.com/Source-Name/002-Product-Name
(3)
www.mysite.com/moto.php?id=005&product=Product-Name&source=Source-Name
should become -> www.mysite.com/Source-Name/005-Product-Name
(4)
www.mysite.com/stores.php?id=002&name=Store-Name
should become -> www.mysite.com/002-Store-Name
Edit: I should have clarified, there are 3 product pages, which should all redirect to the same format URL
Any help much appreciated :)
RewriteEngine On
RewriteRule ^(\d+)-(.+)$ /stores.php?id=$1&name=$2 [L]
RewriteRule ^(.+)/(\d+)-(.+)$ /products.php?id=$2&product=$3&source=$1 [L]
RewriteCond %{REQUEST_URI} www.mysite.com/(.+)/(\d+)-(.+) /products.php?id=$2&product=$3&source=$1
RewriteCond %{REQUEST_URI} www.mysite.com/(\d+)-(.+) /products.php?id=$1&name=$2
I think it work's well ;)
精彩评论