Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

Convert Apache .htaccess to IIS Web.Config


A web.config file is the settings and configuration for applications on IIS Server (ex: Azure Paas Websites ). But what if you’re coming from a Linux host – what then?

Well, there are few options:

1) Online Conversion Tool

As always, please verify the converted web.config rules on a development site before introducing them directly into production.

2) IIS Manager

More on IIS Manager .htaccess conversions here:

3) Manual Conversion

There is a good article on the equivalent components. It can be found here:


Htaccess Component web.config equivalent


<FilesMatch “\.(gif|jpg|^png)$”>

Order allow, deny





<add fileExtension=”.gif” allowed=”true” />
<add fileExtension=”.jpg” allowed=”true” />
<add fileExtension=”.png” allowed=”false” />


Default Document

# Set the default handler.
DirectoryIndex index.php

<remove value=”index.php” />
<add value=”index.php” />

URL Rewriting

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

<rule name=”Imported Rule 1″ stopProcessing=”true”>
<match url=”^(.*)$” ignoreCase=”false” />
<add input=”{HTTP_HOST}” pattern=”^example\.com$” />
<action type=”Redirect” redirectType=”Permanent” url=”{R:1}” />
<rule name=”Imported Rule 2″ stopProcessing=”true”>
<match url=”^(.*)$” ignoreCase=”false” />
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” ignoreCase=”false” negate=”true” />
<add input=”{URL}” pattern=”^/favicon.ico$” ignoreCase=”false” negate=”true” />
<action type=”Rewrite” url=”index.php?q={R:1}” appendQueryString=”true” />

Error Page Redirects / Handling

# Make Application handle any 404 errors.
ErrorDocument 404 /index.php

<!– HTTP Errors section should only be enabled if the “Error Pages”
feature has been delegated as “Read/Write” at the Web Server level.
<remove statusCode=”404″ subStatusCode=”-1″ />
<error statusCode=”404″ prefixLanguageFilePath=”” path=”/index.php” responseMode=”ExecuteURL” />

Directory Browsing


# Don’t show directory listings for URLs which map to a directory.
Options -Indexes

<directoryBrowse enabled=”false” />