【问题标题】:Wordpress on Microsoft-IIS/7.5 Server: Only Home Page works [duplicate]Microsoft-IIS / 7.5服务器上的Wordpress:只有主页有效[重复]
【发布时间】:2020-03-31 04:23:55
【问题描述】:

我最近将一个 Wordpress 站点从 Apache 服务器移动到 Microsoft-IIS/7.5 服务器,问题是,当移动到 IIS 服务器时,只有主页有效。当我转到存档页面或单页时,它返回 404 错误。我认为是因为 IIS 不理解 htaccess 重写 wordpress 中的<IfModule mod_rewrite.c>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

# END WordPress

所以我尝试将上面的 htaccess 转换为 web.cofig,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <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>

但它返回 500 错误。有人知道怎么解决吗?

【问题讨论】:

    标签: wordpress .htaccess iis-7.5


    【解决方案1】:

    .htaccess 文件不适用于 IIS 服务器。您需要编写 web.coconfig 文件而不是 .htaccess 文件,您可以获得更多帮助here

    【讨论】:

      【解决方案2】:

      我意识到我必须为 IIS 安装模块以进行 URL 重写。 http://www.iis.net/download/URLRewrite

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-07-16
        • 1970-01-01
        • 2017-06-28
        • 2013-10-13
        • 2016-11-15
        • 2023-03-04
        • 2012-01-08
        相关资源
        最近更新 更多