在做PHP系统的时候,在win server 2012的iis下面使用会用到url重写,需要省略index.php,所以记录这个重写规则.将以下代码保存在web.config文件里并放在网站根目录,即可实现省略index.php
<?xml version="1.0" encoding="UTF-8"?><configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="WPurls" enabled="true" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php/{R:0}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer></configuration>
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号