Transforming .htaccess into web.config

There are two solutions to convert rules from .htaccess to web.config. The first solution is to use the import feature of the IIS URL Rewrite Module. To do this, go to the IIS Manager, select your site in the tree, double-click URL Rewrite in the Feature View, click Import Rules in the Actions panel, paste your .htaccess rules into the Rewrite rules textbox, and you’ll see your converted rules below. There is more information available about this feature.
Alternatively, the second solution is to install the free version of isapi rewrite and use .htaccess with IIS 7.


As I shift my website from a Linux and Apache-based server environment to IIS-7, I am aware that web.config serves the same purpose as .htaccess. Hence, I am searching for guidance on how to transform the specific lines from my .htaccess file to the web.config file. Can you assist me with where to start?

Options +FollowSymlinks
RewriteEngine On
RewriteRule ([A-Za-z0-9/_-]+).(jp(e?)g|gif|png)$ thumb.php?src=../../uploads/default/files/$1.$2&size=160x90

Solution 1:

One way to transition rules from .htaccess to web.config is by utilizing the import functionality offered by the IIS’s URL Rewrite Module.

  1. navigate to
    the Manager for Internet Information Services (IIS)
  2. click you site in the tree
  3. In the Feature View, click twice on the option labeled URL Rewrite.
  4. Within the Actions panel, simply select the option labeled “Import Rules” by clicking on it.
  5. Copy and paste your .htaccess code into the designated field labeled “Rewrite rules.” Once entered, your modified rules will appear in the section below.

More info about this feature.

As an example, these are the rules that have been transformed:


Solution 2:

To implement the necessary changes, you can either create a new web.config file using Notepad or modify the existing one in the root folder. Once you have done so, simply copy and paste the required code.


Check out the following link for more information:

Frequently Asked Questions