Reversing a mod_rewrite rule

Posted by KIRA on Server Fault See other posts from Server Fault or by KIRA
Published on 2012-11-16T17:39:40Z Indexed on 2012/11/16 23:02 UTC
Read the original article Hit count: 219

Filed under:
|
|

I want to redirect accesses from

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

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]

What changes do I need to make to these rules to redirect requests from the script to the subdomain?

© Server Fault or respective owner

Related posts about .htaccess

Related posts about redirect