0

I would like to redirect this

http://www.domain.com/test.php?sub=subdomain&type=cars

redirects to

http://subdomain.domain.com/cars

I already have mod_rewrite rules to do the opposite:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.com [NC]
RewriteRule (.*) http://www.%2.com/index.php?route=$1&name=%1 [R=301,L]

with htaccess ,help me plz...

1 Answer 1

0

To get the values of 'subdomain' and 'cars' off the query string you need to use RewriteCond %{QUERY_STRING}

I don't know for sure but you could try this:


RewriteCond %{HTTP_HOST} ^www\.(.)\.com
RewriteCond %{QUERY_STRING} ^sub=(.*)&type=(.*)$
RewriteRule (.) http://$2.$1.com/$3 [R=301,L]

2
  • thanks for rapid respons but does not work
    – Ben.
    Oct 17, 2013 at 0:55
  • ugh, i tried to figure it out but no luck, sorry! Oct 17, 2013 at 3:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .