我想重定向此
http://www.domain.com/test.php?sub=subdomain&type=cars
重定向至
http://subdomain.domain.com/cars
我已经有 mod_rewrite 规则来做相反的事情:
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]
使用 htaccess,请帮助我......
答案1
要从查询字符串中获取“subdomain”和“cars”的值,您需要使用RewriteCond %{QUERY_STRING}
我不太确定,但你可以尝试这个:
RewriteCond %{HTTP_HOST} ^www\.(.)\.com
RewriteCond %{QUERY_STRING} ^sub=(.*)&type=(.*)$
RewriteRule (.) http://$2.$1.com/$3 [R=301,L]