1、通过Web.config设置伪静态规则
- <?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>
复制代码
2、通过web.config实现301重定向的方法,将不带www的域名转向到带www的域名上
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="Redirect" stopProcessing="true">
- <match url=".*" />
- <conditions>
- <add input="{HTTP_HOST}" pattern="^safehourse.cn$" />
- </conditions>
- <action type="Redirect" url="http://www.safehourse.cn/{R:0}" redirectType="Permanent" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- </configuration>
复制代码
以上为windows下使用web.config设置伪静态与301重定向的简单操作步骤,祝你成功
|