2013-07-24 37 views
3

我想重定向任何URL統計開始像[subdomain.]example.TLD[/?query_string]example.org[/?query_string]國防部重寫:處理子域,頂級域,查詢字符串

以下規則集各工作正常,但不是在組合。 也就是說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] 

回答

0

你只需要一個規則作爲QUERY_STRING被重定向後自動複製到。

RewriteCond %{HTTP_HOST} !^example\.org$ [NC] 
RewriteRule^http://example.org%{REQUEST_URI} [R=301,L] 
+0

變更後:重定向域的作品,但QUERY_STRING仍然丟失。 –

+0

QUERY_STRING不會按上述規則丟失,請在其他瀏覽器中嘗試。 – anubhava

+0

由於它仍然丟失,它似乎是一個優越的.htaccess正在造成這種情況。我會檢查。 –