use*_*151 6 iis .htaccess server-migration
我正在将一个WordPress博客从Apache移到IIS.这只是几个星期,直到我改变它.但我所能得到的只是主页.其他一切都会引发错误.
我认为我的问题出在.htaccess文件中:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#END WordPress
Run Code Online (Sandbox Code Playgroud)
IIS有什么相同的东西吗?
谢谢.
小智 10
我想你会在这里找到答案 - 如何在IIS 7上设置Wordpress运行中的漂亮永久链接我想你需要在根文件夹中放置一个web.config文件,如:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
<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/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
“漂亮”的永久链接通常需要 mod_rewrite,而 IIS(Windows 服务器上常见)不支持 mod_rewrite。
检查 WordPress Codex,特别是“没有 Mod 重写的永久链接”部分,因为它包含有关您环境中的永久链接的信息(下面的一些信息,请检查链接以获取完整信息,因为它是官方文档):
如果您使用的是 IIS 7 并且拥有服务器的管理员权限,则可以使用 Microsoft 的 URL 重写模块。虽然与 mod_rewrite 不完全兼容,但它确实支持 WordPress 漂亮的永久链接。安装后,打开 WordPress 文件夹中的 web.config 文件并将以下规则添加到 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>
Run Code Online (Sandbox Code Playgroud)