【发布时间】: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