Alternative to Apache’s .htaccess file for IIS?

泄露秘密 提交于 2019-12-07 02:23:51

问题


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.

I think my problem is in the .htaccess file:

# 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?

Thanks.


回答1:


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 :

<?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:


"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support 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):

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.

<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:


"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support 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).




回答4:


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

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.



来源:https://stackoverflow.com/questions/1778095/alternative-to-apache-s-htaccess-file-for-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!