thinkphp在iis7以上如何配置伪静态隐藏index.php

  • 内容
  • 评论
  • 相关

1.如果iis没有安装url重写模块,先下载url重写模块安装上,下载地址:https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=7435

2.下载安装完成之后,通过iis管理器重启iis,然后重新打开iis管理器,发现增加了url重写

3.iis高版本可以在网站根目录配置web.config,实现url重写,从而达到隐藏index.php的目录,web.config示例内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
        <defaultDocument>
            <files>
                <add value="index.php" />
            </files>
        </defaultDocument>
        <handlers>
            <add name="php" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="D:\phpstudy_pro\Extensions\php\php7.3.4nts\php-cgi.exe" resourceType="Unspecified" />
        </handlers>
</system.webServer>
</configuration>

4.需要注意web.config内容,handlers节点下面是php解析器路径,请根据真实情况做出调整。

本文标签:

版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。

本文链接:thinkphp在iis7以上如何配置伪静态隐藏index.php - https://www.wlphp.com/?post=234

发表评论

电子邮件地址不会被公开。 必填项已用*标注