【问题标题】:Redirect old domain https to new domain https将旧域 https 重定向到新域 https
【发布时间】:2018-01-07 22:01:56
【问题描述】:

我做了一些从旧域到新主机上的新域的重定向 301。但是我检查了旧主页站点的 HTTPS 版本仍在工作并且没有重定向到新域,但是旧主页上的链接正在重定向到新域链接。如何将旧域的 HTTPS 版本重定向到新域的 HTTPS 版本?以下是我的 .htaccess 的一部分

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{THE_REQUEST} /store/catalogsearch/result/index/ [NC]
RewriteRule ^ https://www.newdomain.com/? [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index)\.(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ http://www.newdomain.com/$1 [R=301,NC]
RewriteRule ^store/?$ http://www.newdomain.com [L,NC,R=301]
RewriteRule ^store/folder/?$ http://www.newdomain.com/otherfolder/another-folder/ [L,NC,R=301]
RewriteRule ^store/folder1/folder2/?$ http://www.newdomain.com/folder-3/folder-4 [L,NC,R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,NE,L]

提前感谢您的帮助。

【问题讨论】:

    标签: php apache .htaccess magento redirect


    【解决方案1】:

    在 htaccess 文件中,您必须只输入条件和规则才能完成您的工作。

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www.olddomain.com$
        RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
    </IfModule>
    

    在您的代码中,您在不正确的新域名前写下了 ^ 符号。

    【讨论】:

      【解决方案2】:

      // 试试这个..

       <IfModule mod_rewrite.c>
        RewriteEngine On
        Redirect 301 / http://newdomain.com/
       </IfModule>
      
      OR
      
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^(www\.)?http://olddomain\.com$
        RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,QSA,L]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-25
        • 2018-04-27
        • 1970-01-01
        • 2016-02-18
        • 2022-01-14
        • 1970-01-01
        • 2018-06-07
        相关资源
        最近更新 更多