wordpress系统建设网站如何将 HTTP 重定向到 HTTPS

2020-02-25 23:53 admin
  wordpress系统建设网站如何将 HTTP 重定向到 HTTPS ?邯郸专业网站建设工作人员说wordpress系统建设网站重定向到 HTTPS 协议在 Windows 上安全您 WordPress 建站,有几个步骤,需要采取之前重定向将正常工作。

WordPress 准备步骤

修改任何代码之前应这些步骤。

  1. 登录到 WordPress
  2. 选择设置从菜单,单击常规.
  3. 常规设置中找到以下项:
    • WordPress 地址 (URL):
    • 网站地址 (URL):
  4. 更新包括这两个 URLhttps而不是http
  5. 保存更改

Windows 重定向步骤

如果在 Windows 上托管您的 WordPress 建站,它将使用web.config 配置文件.订购web.config您的网站的根目录中将更改您的网站的行为时检测到并执行该文件。

  1. 下载的副本您web.config从您的主机账户。
  2. 使用您喜爱的文本编辑器中打开文件

     注意:请确保您编辑 web.config 文件使用纯文本编辑器,不使用自动换行。(例如 MS Word 或启用自动换行使用 Notepad) 某些编辑器将插入无形的字符指示换行。如果网站上的有以下特殊字符,web.config 文件都不会工作。

  3. 进行必要的更改 (请参阅示例 belowe)。
  4. 保存您的更改。
  5. 上传已修改web.config到您的主机账户。
  6. 通过导航到通过 HTTP 协议的网站来测试您的工作,它应该将重定向到 HTTPS 自动。

示例 WordPress web.config 内容

您的 WordPress 网站应中已经有一个默认项您web.config文件。它看起来应该类似于以下示例:

  <?xml version="1.0" encoding="UTF-8"?>
  <configuration>
  <system.webServer>
  <rewrite>
  <rules>
  <rule name="WordPress Rule" stopProcessing="true">
  <match url=".*" />
  <conditions>
  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  </conditions>
  <action type="Rewrite" url="index.php" />
  </rule>
  </rules>
  </rewrite>
  </system.webServer>
  </configuration>

为了确保您的主机账户将到网站上的所有通信中强制 HTTPS 协议,您将需要向 web.config 文件中添加以下。

<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" />
</rule>

您将需要发布后的代码片段rulesweb.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" />
</rule>
<rule name="WordPress Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
 

在线咨询 拨打电话

电话

13363039260

微信二维码

微信二维码