【问题标题】:Redirect single page http to https将单页 http 重定向到 https
【发布时间】:2013-04-15 16:44:29
【问题描述】:

我正在尝试使用 .htaccess 将单个页面从 http 重定向到 https,但我不断收到重定向循环错误。

代码:

Redirect /secureform.html https://www.example.com/secureform.html

但是,我不断收到“此网页的重定向过多”错误。如何避免这种情况发生?

【问题讨论】:

    标签: .htaccess http redirect https http-redirect


    【解决方案1】:

    试试这个:

    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteRule ^secureform\.html$ https://www.example.com/secureform.html [L,R=301]
    

    【讨论】:

    • @LizReeder 欢迎来到 SO。如果这个答案解决了你的问题,考虑accepting吧。
    • rewriteRule 可以更通用地编写,使用%{HTTP_HOST}%{REQUEST_URI} 可能会使其更便携,例如:RewriteRule ^secureform\.html$ %{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    【解决方案2】:

    我已经尝试过了,它对我有用:

    Redirect permanent /secure https://www.example.com
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-03
      • 2011-10-31
      • 2013-04-09
      • 1970-01-01
      • 1970-01-01
      • 2018-03-19
      • 2016-05-15
      • 2013-10-18
      相关资源
      最近更新 更多