2
votes

I have the following rewrite configuration in my .htaccess file which is working fine in apache server but its not working properly in IIS server.

Options +FollowSymlinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^myservername/$ [NC]
RewriteRule ^(.*)$ http://myservername/$1 [R=301,L]
RewriteRule !\.(php|png|gif|jpg|css|htm|html|txt|js|swf|xml|ico|mp3|csv|wav|mid) /index.php [L,QSA]

How do I get this working on IIS?

2
You don't. .htaccess files are Apache specific.Pekka

2 Answers

5
votes

IIS doesn't support .htaccess out of the box. To use Apache style mod_rewrite rules on IIS you'll need a third party rewriter such as Iconics ISAPI Rewrite Filter or HeliconTech's ISAPI_Rewrite. You'll probably need to tweak the rewrite rules because not all of mod_rewrite's directives are supported or applicable (because Windows is not Unix).

If you're running IIS7 and it has UrlRewriter installed (which is free) you could use that but you'd need to convert your rewrite rules to a completely different format.

2
votes

please create new file with name web.config and paste the following

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^.*$" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile"  />                      
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^(.*)$" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>