PHP菜鸟博客_共同学习分享PHP技术心得【PHP爱好者】
thinkphp在iis7以上如何配置伪静态隐藏index.php
2020-12-11 菜鸟站长


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解析器路径,请根据真实情况做出调整。

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容