3

I'd like to redirect any URL stat starts like [subdomain.]example.TLD[/?query_string] to example.org[/?query_string]

Following rule sets each are working, but not in combination. I.e. www.example.com => example.org example.com/?query_string => example.org/?query_string

RewriteEngine On

RewriteCond %{HTTP_HOST} !=example.org
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(.*)$ http://example.org/$1?%{QUERY_STRING} [R=301,L]

RewriteCond %{HTTP_HOST} !=example.org
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ http://example.org/$1 [R=301,L]
4

1 回答 1

0

您只需要一条规则,因为 QUERY_STRING 会在重定向后自动复制到。

RewriteCond %{HTTP_HOST} !^example\.org$ [NC]
RewriteRule ^ http://example.org%{REQUEST_URI} [R=301,L]
于 2013-07-25T06:57:55.277 回答