TypechoJoeTheme

至尊技术网

统计
登录
用户名
密码
/
注册
用户名
邮箱

悠悠楠杉

网站页面

IIS如何做http跳转https和伪静态的设置

2019-08-16
/
0 评论
/
701 阅读
/
正在检测是否收录...
08/16

网站的程序是wordpress,运行的web服务器 IIS ,网站升级成了https, 需要在 服务器 中做两个设置。

第一: 跳转设置,从 http 跳转到 https 。

第二: 支持伪静态,这里简单粗暴的方式,设置的是如果文件不存在,就重写到 index.php ,然后执行wordpress。

完整的web.config 文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" />
                </rule>
                <rule name="wordpress rewrite" enabled="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

http 跳转到 https 的设置

<rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" />
</rule>

对于任何地址,如果不是 https 就跳转到 https , {R:0} 表示url中域名之后的部分。

伪静态的支持

<rule name="wordpress rewrite" enabled="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" />
</rule>

伪静态就做了一点,就是文件不存在,就去执行'index.php'

经验
朗读
赞(0)
版权属于:

至尊技术网

本文链接:

https://www.zzwws.cn/archives/562/(转载时请注明本文出处及文章链接)

评论 (0)