繁体   English   中英

RedirectMatch 301的同一页面URL到多个TLD

[英]RedirectMatch 301s same page URL to multiple TLDs

目前,我们正在一家magento商店中工作,该商店先前已实现了多个301重定向。 原始的.htaccess文件具有很多规则,例如:

RedirectMatch 301 ^/original-page.html http://www.yourdomain.co.uk/our-new-directory/new-page.html
RedirectMatch 301 ^/original-page2.html http://www.yourdomain.co.uk/our-new-directory/new-page2.html 
RedirectMatch 301 ^/original-page3.html http://www.yourdomain.co.uk/our-new-directory/new-page3.html

该网站现在有了新的TLD设置,因此,如果您访问http://www.yourdomain.de/original-page.html ,您将被重定向到http://www.yourdomain.co.uk/our- new-directory / new-page.html

我想要做的就是拥有它,以便我们具有以下功能:

有人输入:

http://www.yourdomain.co.uk/original-page.html and gets redirected to http://www.yourdomain.co.uk/our-new-directory/new-page.html

http://www.yourdomain.de/original-page.html and gets redirected to http://www.yourdomain.de/our-new-directory/new-page.html

从本质上讲,重定向应考虑用户所在的TLD。 造成这种情况的主要原因是,网站上的许多页面都有301重定向到的URL。

在这方面的任何帮助将是出色的。

亲切的问候,刘易斯

将此代码放在您的DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.yourdomain\. [NC]
RewriteRule ^original-page\.html$ http://%{HTTP_HOST}/our-new-directory/new-page.html [R=301,L]

您只需删除重定向的主机名部分即可:

RedirectMatch 301 ^/original-page.html /our-new-directory/new-page.html
RedirectMatch 301 ^/original-page2.html /our-new-directory/new-page2.html 
RedirectMatch 301 ^/original-page3.html /our-new-directory/new-page3.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM