将域重定向到保留链接的新域



好的,所以我有一个网站,比如oldwebsite.com.au和一个新网站,比如newwebsite.com.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

不要将mod_alias规则与mod_rewrite规则混合使用。像这样访问.hta:

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规则。

我不确定,但你可以试试这个

以下重定向规则:

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

最新更新