环境IIS10
IIS重写组件用于配置伪静态规则
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <system.webServer>
- <defaultDocument>
- <files>
- <add value="index.php" />
- </files>
- </defaultDocument>
- <handlers>
- <add name="PHP" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\php\php-cgi.exe" resourceType="File" />
- </handlers>
- <rewrite>
- <rules>
- <rule name="reIndex">
- <match url="^(.*)$" />
- <conditions>
- <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
- <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
- </conditions>
- <action type="Rewrite" url="index.php?p={R:1}" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- </configuration>
IIS重写组件下载地址
此处为最新版本,直接安装即可,老版本Win10安装时会报错,解决方法如下:
打开注册表编辑器,在HKEY_LOCAL_MACHINE-SOFTWARE-Microsoft-InetStp位置把MajorVersion的值改为9之后,就可以安装了,安装完成之后,再把MajorVersion的值改回10。
如果系统更新后会出现IIS起不来,那么也是上面这个问题,需要改回9后修复一下即可。
URL重写规则
上述代码使用iis的重写功能




