2014-08-28 70 views
1

好了,所以我有一個網站說oldwebsite.com.au和一個新的網站說newwebsite.com.au重定向域名新域名保持聯繫

我需要重定向,並保持所有的鏈接從交通因此舊的網站。

所以我用它作爲重定向(下圖)。唯一的問題是我有幾個頁面的URL結構已經改變,我需要添加這些被分開重定向我試圖在整個網站重定向之前添加重定向,但它似乎沒有工作任何幫助將大大讚賞。

#Redirects for individual url that changed. (Not working) 
Redirect 301 /about-us.php https://newwebsite.com.au/about-us/ 
Redirect 301 /category/old-page https://newwebsite.com.au/new-page/ 


#Redirects for the whole site. 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} !=old.oldwebsite.com.au 
RewriteCond %{HTTP_HOST} !^newwebsite\.com.au 
RewriteRule (.*) https://newwebsite.com.au/$1 [R=301,L] 

注:個別URL重定向工作,如果我刪除整個網站重定向... 注:林腐也重定向子域名old.oldwebsite.com.au

+0

哪個網址沒有被重定向到新網站? – anubhava 2014-08-28 07:41:38

+0

重定向301 /about-us.php https://newwebsite.com.au/about-us/ 重定向301 /類別/舊頁面https://newwebsite.com.au/new-page/ – STiTCHiCKED 2014-08-28 08:28:27

回答

1

不要mod_rewrite混用mod_alias規則。有你的.htaccess這樣的:

Options +FollowSymLinks 
RewriteEngine on 

# skip subdomain from further rules: 
RewriteCond %{HTTP_HOST} =old.oldwebsite.com.au 
RewriteRule^- [L] 

RewriteRule ^about-us\.php$ https://newwebsite.com.au/about-us [R=301,L,NE,NC] 

RewriteRule ^category/old-page/?$ https://newwebsite.com.au/new-page/ [R=301,L,NE,NC] 

RewriteCond %{HTTP_HOST} !^newwebsite\.com\.au$ [NC] 
RewriteRule (.*) https://newwebsite.com.au/$1 [R=301,L,NE] 

而且不要忘記刪除所有Redirect規則。

+0

感謝您的,現在似乎都在工作。我將在未來記住這一點。 +1 – STiTCHiCKED 2014-08-28 08:48:47

+1

不客氣,很高興它的工作。 – anubhava 2014-08-28 08:49:19

+0

我已經進入一個輕微的問題與重定向:old.oldwebsite.com.au子域名,因爲它獲取重定向相同oldwebsite.com.au – STiTCHiCKED 2014-08-28 12:34:11

0

我不是知道,但你可以試試這個

以下的重定向規則:

<rule name="Canonical Host Name" stopProcessing="true"> 
<match url="(.*)" /> 
<conditions> 
<add input="{HTTP_HOST}" pattern="^www\example.com" /> 
</conditions> 
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" /> 
</rule>