在IIS环境配置TP5项目 隐藏index.php文件的方法

时间:2024-04-09 17:22:15

我们一般项目都市apahce下配置伪静态都时.htaccess文件 写伪静态规则! 但是在西部数码这种服务器下他的环境时IIS 所以你的伪静态文件是不会起作用的! 那么在IIS下如何隐藏index.php呢?如下

首先IIS 需要 添加重写模块URL Rewrite

在IIS环境配置TP5项目 隐藏index.php文件的方法

 

在IIS环境配置TP5项目 隐藏index.php文件的方法

在入口文件同级目录下建立web.config文件。文件内容如下。

切记是 index,php同级目录哦!!

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="OrgPage" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^(.*)$" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>