我想从url中删除index.php,我使用的是wordpress和iis7。我该怎么做这个
使用此web.config
(web.config是相当于apache webserver中.htaccess文件的IIS。它可以在根文件夹中找到。如果没有,则需要创建一个。)
<?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在下面的评论)
在使用Windows Azure网站的情况下,另一个非常快速的解决方案是使用Microsoft WebMatrix
登录到您的网站,并创建一个web.config文件,正如本文所指出的。这就解决了问题。不需要自己安装URL Rewrite extension
或类似的东西。MS Webmatrix似乎很容易解决这个问题。