IIS的Apache .htaccess文件的替代方案?

时间:2021-05-11 13:25:47

I'm moving a WordPress blog from Apache to IIS. It's just for a couple weeks until I get it changed out. But all I can get to is the homepage. Everything else throws errors.

我正在将一个WordPress博客从Apache移到IIS。这只是几个星期,直到我改变它。但我所能得到的只是主页。其他一切都会引发错误。

I think my problem is in the .htaccess file:

我认为我的问题出现在.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

Is there something equivalent to this for IIS?

IIS有什么相同的东西吗?

Thanks.

谢谢。

4 个解决方案

#1


10  

I think you would find the answer here - How To Set Pretty Permalinks in Wordpress Runs On IIS 7 I guess you need to put one web.config file in the root folder like :

我想你会在这里找到答案 - 如何在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>

#2


2  

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite.

“漂亮”永久链接通常需要mod_rewrite,而IIS(Windows服务器上常见)不支持mod_rewrite。

Check Wordpress Codex, specifically Permalinks Without Mod Rewrite section since it has information about permalinks in your environment (some information below, check the link for full information since it's the official documentation):

检查Wordpress Codex,特别是没有Mod Rewrite的永久链接部分,因为它有关于您环境中永久链接的信息(下面的一些信息,请查看链接以获取完整信息,因为它是官方文档):

If you are using IIS 7 and have admin rights on your server, you can use Microsoft's URL Rewrite Module instead. Though not completely compatible with mod_rewrite, it does support WordPress's pretty permalinks. Once installed, open the web.config file in the WordPress folder and add the following rule to the system.webServer element.

如果您使用的是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>

#3


1  

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite.

“漂亮”永久链接通常需要mod_rewrite,而IIS(Windows服务器上常见)不支持mod_rewrite。

whether you are using IIS6 or 7, you can also use a rewriting engine on IIS - many of them support mod_rewrite syntax.
IIRF is a good one, works with both IIS6 and 7. (Vista, WS2003, 2008).

无论您使用的是IIS6还是7,您还可以在IIS上使用重写引擎 - 其中许多都支持mod_rewrite语法。 IIRF是一个很好的,适用于IIS6和7.(Vista,WS2003,2008)。

#4


0  

Wound up doing a new install of WordPress then selectively importing the tables.

重新安装WordPress,然后有选择地导入表。

The problem was the permalinks of course. But I found the easiest way to fix it was to use the same structure permalinks the old site did (luckily it hasn't been deleted yet so I could find it in the admin) and then importing everything except the user tables.

当然,问题是固定链接。但我发现修复它的最简单方法是使用旧网站所做的相同结构永久链接(幸运的是它还没有删除,所以我可以在管理员中找到它)然后导入除用户表之外的所有内容。

If you import the user tables, you lose the admin login from the new setup.

如果导入用户表,则会丢失新安装程序中的管理员登录名。

#1


10  

I think you would find the answer here - How To Set Pretty Permalinks in Wordpress Runs On IIS 7 I guess you need to put one web.config file in the root folder like :

我想你会在这里找到答案 - 如何在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>

#2


2  

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite.

“漂亮”永久链接通常需要mod_rewrite,而IIS(Windows服务器上常见)不支持mod_rewrite。

Check Wordpress Codex, specifically Permalinks Without Mod Rewrite section since it has information about permalinks in your environment (some information below, check the link for full information since it's the official documentation):

检查Wordpress Codex,特别是没有Mod Rewrite的永久链接部分,因为它有关于您环境中永久链接的信息(下面的一些信息,请查看链接以获取完整信息,因为它是官方文档):

If you are using IIS 7 and have admin rights on your server, you can use Microsoft's URL Rewrite Module instead. Though not completely compatible with mod_rewrite, it does support WordPress's pretty permalinks. Once installed, open the web.config file in the WordPress folder and add the following rule to the system.webServer element.

如果您使用的是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>

#3


1  

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite.

“漂亮”永久链接通常需要mod_rewrite,而IIS(Windows服务器上常见)不支持mod_rewrite。

whether you are using IIS6 or 7, you can also use a rewriting engine on IIS - many of them support mod_rewrite syntax.
IIRF is a good one, works with both IIS6 and 7. (Vista, WS2003, 2008).

无论您使用的是IIS6还是7,您还可以在IIS上使用重写引擎 - 其中许多都支持mod_rewrite语法。 IIRF是一个很好的,适用于IIS6和7.(Vista,WS2003,2008)。

#4


0  

Wound up doing a new install of WordPress then selectively importing the tables.

重新安装WordPress,然后有选择地导入表。

The problem was the permalinks of course. But I found the easiest way to fix it was to use the same structure permalinks the old site did (luckily it hasn't been deleted yet so I could find it in the admin) and then importing everything except the user tables.

当然,问题是固定链接。但我发现修复它的最简单方法是使用旧网站所做的相同结构永久链接(幸运的是它还没有删除,所以我可以在管理员中找到它)然后导入除用户表之外的所有内容。

If you import the user tables, you lose the admin login from the new setup.

如果导入用户表,则会丢失新安装程序中的管理员登录名。