开发者

Alternative to Apache’s .htaccess file for IIS?

开发者 https://www.devze.com 2022-12-12 18:10 出处:网络
I\'开发者_JAVA技巧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'开发者_JAVA技巧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.


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>


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


"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).


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消