How to convert a .htaccess file for use in your Web.Config file on Windows Server

How to convert a htaccess file for use on Windows Server

If you're running a Windows Server and you have to run PHP websites on it chances are that you will be asked to apply rules from a .htaccess file to one of the websites on your server. Windows Server does not use .htaccess files. These usually come from Apache servers. However, Windows Servers use a similar file called the Web.Config file located at the root of all your websites hosted on your Windows Server.

You'll be glad to know that there is a converter built into IIS 7 that will convert any .htaccess rules into the format required for the Web.Config file. To convert your .htaccess file simply follow these instructions:

  1. Log onto your server and open IIS.
  2. Double click on the 'URL Rewrite' icon from the list under 'IIS'.
  3. Click on 'Import Rules...' from the right side bar.
  4. Copy the htaccess contents supplied to you and paste them into the 'Rewrite Rules' text box. Once pasted you should notice the 'Converted Rules' area will update. If you click on the XML tab you will see the Web.Config format of the rule entered.
  5. Ensure you're looking at the Tree tab and right click on the 'rule name' tag in the Tree View and click on 'Rename' to rename the rule to something other than 'Imported Rule 1' so it will make more sense to anyone looking at the web.config file later on.
  6. Click on 'Apply' from the right side bar and your rule will be added to your web.config file.

That's it. You're all done! Nice and easy.

blog comments powered by Disqus

Get In Touch

Follow me online at TwitterFacebook or Flickr.

Latest Tweets