【问题标题】:Redirection from http to https is not working从 http 到 https 的重定向不起作用
【发布时间】:2018-05-02 17:54:41
【问题描述】:

重写引擎开启 重写条件 %{SERVER_PORT} !443 RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]

这是我在 .htaccess 文件中使用的命令,当我键入 arion-software.co.uk 时,它没有正确重定向。 有什么想法吗?

【问题讨论】:

  • 我很好奇这些答案是否符合您的查询?

标签: apache .htaccess redirect mod-rewrite https


【解决方案1】:

好了,http 到 https 重写:

## Redirecting HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

【讨论】:

    【解决方案2】:

    这应该可以,它对我有用。

    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
    

    这就是我的来源:redirect http to https

    编辑:该链接为您的域提供了带有或不带有“www”的示例。子域。

    【讨论】:

      【解决方案3】:
      RewriteEngine On
      RewriteCond %{HTTPS} off
      # First rewrite to HTTPS:
      # Don't put www. here. If it is already there it will be included, if not
      # the subsequent rule will catch it.
      RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
      # Now, rewrite any request to the wrong domain to use www.
      # [NC] is a case-insensitive match
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
      

      【讨论】:

        猜你喜欢
        • 2018-09-08
        • 2014-03-10
        • 2018-06-11
        • 2015-07-28
        • 2018-03-27
        • 2018-10-25
        • 2022-01-14
        • 2021-04-15
        • 2018-01-31
        相关资源
        最近更新 更多