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

标签 php wordpress iis-7 url-rewriting permalinks

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

最佳答案

使用这个 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 在下方的评论)

关于php - 从 iis7 中的 wordpress URL 中删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12106064/

相关文章:

php - 使用它的 id 设置 Symfony2 实体表单字段

php - 如何在onchange时显示数据库信息

c# - 使用 ServerManager 类配置 IIS 身份验证设置

php - 将多个数据输入数据库

php - Magento 一页结帐问题未加载送货地址后

css - Wordpress(avada 主题)谷歌字体拉丁扩展不起作用

php - Wordpress - 分页和自定义数据库查询

css - 删除 wordpress 管理菜单区域

php - 是否需要运行 mysql 服务器才能加载 php_mysql.dll 扩展

asp.net-mvc-2 - 是否有支持 HTTPS 的 IIS 的免费替代品?