【问题标题】:Redirect single HTTP URL to HTTPS via .htaccess通过 .htaccess 将单个 HTTP URL 重定向到 HTTPS
【发布时间】:2019-02-18 06:52:20
【问题描述】:

我创建了一个新网站。旧的使用 http,新的使用 https,并且 URL 路径不同。

例子:

OLD: website.com/index.php/powerpoint-presentation

NEW: https://website.com/powerpoint-presentation

如何以这种方式在 .htaccess 中定向单个 URL?我想做大约 10 次手动 301 重定向。

【问题讨论】:

    标签: .htaccess http redirect https url-redirection


    【解决方案1】:

    在您的 .htaccess 文件中的旧网站上,您可以使用如下内容:

    Redirect 301 /index.php/powerpoint-presentation https://website.com/powerpoint-presentation
    

    您当然可以根据需要使用任意数量。

    【讨论】:

      【解决方案2】:

      可以像 Dave 提到的那样完成单个重定向:

      Redirect 301 /index.php/powerpoint-presentation https://website.com/powerpoint-presentation
      

      但是,如果您所有的旧 URL 的结构都相同,并且您只想删除 /index.php/,您可以这样做:

      RewriteEngine On
      RewriteRule ^index\.php/(.*)$ https://website.com/$1 [R=301,L]
      

      这会将任何具有旧 /index.php/ 结构的 URL 重定向到 https:// 网站上没有 /index.php/ 的相同 URL

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-12
        • 1970-01-01
        • 1970-01-01
        • 2013-09-08
        • 1970-01-01
        相关资源
        最近更新 更多