【发布时间】:2012-08-19 19:42:14
【问题描述】:
我想从 url 中删除 index.php,我正在使用 wordpress 和 iis7。 我该怎么做呢
【问题讨论】:
-
这些答案中的任何一个解决了您的问题吗?
标签: php wordpress iis-7 url-rewriting permalinks
我想从 url 中删除 index.php,我正在使用 wordpress 和 iis7。 我该怎么做呢
【问题讨论】:
标签: php wordpress iis-7 url-rewriting permalinks
使用这个 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 的评论)
【讨论】:
在您使用 Windows Azure 网站的情况下,另一个非常快速的解决方案是使用 Microsoft WebMatrix 登录到您的网站并创建一个 web.config 文件 as this article pointed out。这样就解决了。无需自己安装URL Rewrite extension 或类似的东西。 MS Webmatrix 似乎很容易解决这个问题。
【讨论】: