【问题标题】:.htaccess redirect to https is not working.htaccess 重定向到 https 不起作用
【发布时间】:2018-04-29 11:41:10
【问题描述】:

我数小时都在摸不着头脑,尝试了许多解决方案,但仍然无法将我的网站重定向到 https

下面是我的.htaccess

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

另一个 .htaccess 我试过了:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

两者都不起作用,我还在 stackoverflow 上尝试了许多其他解决方案。但没有一个工作。 作为参考,这里是https Link of my website.

【问题讨论】:

  • 注意:我的主机来自 Godaddy。

标签: .htaccess redirect url-redirection http-redirect


【解决方案1】:

一年前我遇到了这个问题。尝试在您放置 .htaccess 文件的根目录中添加 web.config 文件。

web.config中复制并粘贴以下代码:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Redirect to https" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

【讨论】:

    【解决方案2】:

    试试

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-14
      • 2017-06-21
      • 2018-09-08
      • 2016-04-12
      • 1970-01-01
      • 2016-05-24
      • 2023-03-03
      • 2013-09-08
      相关资源
      最近更新 更多