|
(转载的,应该靠谱)
今天打开自己的博客,发现网站的内页都不能访问了,我用的是Windows主机空间,主机支持Rewrite。win主机不能像Linux主机空间那样直接在后台设置固定链接,如果你要修改的话,链接中一定要带index.php这个,否则就会提示系统找不到文件。。问了度娘和谷歌,答案是可以通过404跳转或httpd.ini达到wordpress固定链接静态化的目的,但怎么也实现不了。无奈,又问度娘和谷歌,终于找到一种方法,使用web.config设置wordpress固定链接静态化:
- <?xml version=”1.0″ encoding=”UTF-8″?>
-
- <configuration>
-
- <system.webServer>
-
- <httpErrors errorMode=”Detailed” />
-
- <asp scriptErrorSentToBrowser=”true”/>
-
- <rewrite>
-
- <rules>
-
- <clear />
-
- <rule name=”wordpress” 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” />
-
- </rule>
-
- <rule name=”chinese tag” stopProcessing=”true”>
-
- <match url=”/tag/(.*)” />
-
- <conditions logicalGrouping=”MatchAll” />
-
- <action type=”Rewrite” url=”/index.php?tag={R:1}” />
-
- </rule>
-
- <rule name=”www” stopProcessing=”true”>
-
- <match url=”.*” />
-
- <conditions>
-
- <add input=”{HTTP_HOST}” pattern=”^urlt$” />
-
- </conditions>
-
- <action type=”Redirect” url=”http://www.url/{R:0}” redirectType=”Permanent” />
-
- </rule>
-
- </rules>
-
- </rewrite>
-
- </system.webServer>
-
- </configuration>
复制代码 特别说明:
1. 该段代码只有IIS 7以上能生效。里面的www.url替换成自己的域名哦
|
|