views:

17

answers:

1

How can I rewrite the following:

http://www.mydomain.com/my-page.html to http://www.mydomain.com/my-page.html?type=1

Tried the following without any luck:

RewriteRule /car-covers.html$ /car-covers.html?type=$1 [R=301,L]

RewriteRule ^car-covers.html$ car-covers.html?type=$1 [QSA,L]
A: 

With RewriteRule you can only test the URI path but not the query. You need to use RewriteCond to do so, for example:

RewriteCond %{QUERY} !(^|&)type=
RewriteRule ^car-covers\.html$ car-covers.html?type=$1 [QSA,L]

This will add the parameter type to the query and do an internal rewrite. If you want an external redirect, add the R flag.

Gumbo