WordPress去除index.php后文章頁打不開的解決辦法

字號:


    今天打開自己的博客,發(fā)現(xiàn)網(wǎng)站的內(nèi)頁都不能訪問了,我用的是Windows主機空間,主機支持Rewrite。win主機不能像Linux主機空間那樣直接在后臺設置固定鏈接,如果你要修改的話,鏈接中一定要帶index.php這個,否則就會提示系統(tǒng)找不到文件。。問了度娘和谷歌,答案是可以通過404跳轉或httpd.ini達到wordpress固定鏈接靜態(tài)化的目的,但怎么也實現(xiàn)不了。無奈,又問度娘和谷歌,終于找到一種方法,使用web.config設置wordpress固定鏈接靜態(tài)化:
    <?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下能生效。
    好吧,最后我的問題得到了完美的解決。不知道怎樣想的,win主機商升級了,都不告訴我一下啊。