2014-08-28 71 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>