Partager via


Converting Apache .htaccess rules to IIS web.config using IIS Manager for Azure Websites

Web.config - the settings and configuration file for a Windows IIS Web Application.

.htaccess - the default filename of the directory-level configuration file for a Linux Apache Web Application.


Disclaimer: The URL Rewrite tool by IIS Manager gives you suggested web.config rules. Since it is not a one-to-one conversion, the recommendation is to test these rules in a development environment.


If you’re looking to create rewrite rules for the URL Rewrite Module, please see the article here.

 

These screenshots were taken from IIS Manager 8.6.9600 and assume you have URL Rewrite Installed.

To convert .htaccess rules to web.config, launch IIS Manager.

 

Step 1. In the connections pane, select your site

 

Step 2. Double-click on URL Rewrite

 

 

Step 3. On the right, select “Import Rules”

 

 

 

 

 

Step 4. Copy-paste your .htaccess file or select it under “Configuration file”

 

 

 

Step 5. Click the “Xml view” to view in the web.config format

 

Now that you have the rules in web.config format, validate and verify the rules on a development server.

Comments

  • Anonymous
    May 25, 2015
    Does this solution update web.config automatically when .htaccess rewrites are modified after the first time? My azure site runs Magento/PHP/Ubuntu so by default rewrites are placed in the .htaccess file. Will I have to go through this process each time I add new rewrites? Will it create duplicates if I run the process on the same file multiple times?

  • Anonymous
    June 23, 2015
    Hi crmapley, Great question. This post does not apply to Linux VMs (such as Ubuntu). I will make a note of that in the blog. This is if your site is running on a Windows IIS server / Azure Web App.

  • Anonymous
    November 17, 2015
    THANk YOU! Great post! Fixed my problem for trying to run a kirby install under IIS