Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to Apache’s .htaccess file for IIS?

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.

like image 386
user80151 Avatar asked Nov 22 '09 07:11

user80151


2 Answers

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>
like image 168
Geek Blogger Avatar answered Sep 26 '22 12:09

Geek Blogger


"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>
like image 43
GmonC Avatar answered Sep 22 '22 12:09

GmonC