从iis7中的wordpress URL中删除index.php

时间:2012-08-24 08:51:40

标签: php wordpress iis-7 url-rewriting permalinks

我想从url中删除index.php,我正在使用wordpress和iis7。 我怎么能这样做

2 个答案:

答案 0 :(得分:10)

使用此web.config

(web.config是IIS等同于apache webservers中的.htaccess文件。它可以在根文件夹中找到。如果没有,则需要创建一个。)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
 <defaultDocument>
     <!-- Set the default document -->
      <files>
        <remove value="index.php" />
        <add value="index.php" />
      </files>
    </defaultDocument>
        <httpErrors errorMode="Detailed"/>
    <rewrite>
        <rules>
            <rule name="wordpress" patternSyntax="Wildcard">
                <match url="*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                <action type="Rewrite" url="index.php" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

然后在永久链接页面中,设置“自定义结构”并赋予值/%postname%/

请注意,需要安装特定于IIS版本的URL重写模块才能实现此功能(感谢@ Spikolynn的评论)

答案 1 :(得分:0)

在您使用Windows Azure网站的情况下,另一个非常快速的解决方案是使用Microsoft WebMatrix登录您的网站,只创建一个web.config文件as this article pointed out。这解决了它。无需自己安装URL Rewrite extension或类似的东西。 MS Webmatrix似乎很容易解决问题。

相关问题