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

ras*_*111 8 php wordpress iis-7 permalinks url-rewriting

我想从url中删除index.php,我正在使用wordpress和iis7.我怎样才能做到这一点

Bin*_*nod 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>
Run Code Online (Sandbox Code Playgroud)

然后在永久链接页面中,设置"自定义结构"并给出值 /%postname%/

请注意,需要安装特定于IIS版本的URL重写模块才能使其正常工作(感谢@ Spikolynn的评论如下)


ola*_*jee 0

在您使用 Windows Azure 网站的情况下,另一个相当快速的解决方案是登录Microsoft WebMatrix您的网站并创建一个 web.config 文件,如本文所述。这样就解决了。无需自己安装URL Rewrite extension或类似的东西。MS Webmatrix 似乎很容易解决这个问题。