How To Enable mod_rewrite On IIS

How To Enable mod_rewrite On IIS

The IIS mod_rewrite is a helpful URL rewriting feature of IIS. It lets you rewrite URL by implementing custom rules and get the most out of your web application. Microsoft URL Rewrite module offers you similar functionality like Apache mod_rewrite module.

URL Rewrite Module tries to convert Apache mod_rewrite rules to equivalent IIS URL rewrite rules. It also plays an important role in SEO, preventing unwanted traffic or redirecting requests. In this tutorial, you will learn how you can enable the mod_rewrite feature on IIS.

Prerequisites

  • URL Rewrite module Installer
  • Correct Registry settings
  • Domain name

Step 1

Click on Start menu. Click on Control Panel. Click on Program & Features. Enable IIS from the Add/Remove feature from the control panel if it is not selected at first.

After enabling IIS, Install the URL Rewrite module if it is not previously installed. The module can downloaded from this website.

You might face an issue if you have a windows 10 machine. There is a workaround for that. Click on Start menu, and Click on Run. Open the Registry editor by typing in regedi at the Run menu.

Inside the Registry, navigate to

HKEY_LOCAL_MACHINESOFTWAREMicrosoftInetStpMajorVersion

Make changes in the MajorVersion and set the Decimal to 9. Hit F5 in the registry editor. Now Install the Rewrite module and then change back the decimal value back to 10 and close the Registry editor.

Step 2

To verify if the installation of IIS is successful, type localhost in the URL section of your browser. Make sure other tools like Xampp , wamp are turned off as it may interfere with localhost of IIS.

The above information will be displayed if IIS has been enabled successfully on your machine.

Step 3

Click on Start. Start IIS Manager by running inetmgr on the Run window (window key+R)

Step 4

Open the IIS Manager and Click URL Rewrite from the IIS menu window.

Step 5

Click Open Feature from the right side menu while selecting URL Rewrite.

Step 6

Click Add Rule from the right side menu. A window to add new rule will be displayed with different rules like Inbound rule, outbound rule and SEO options. Click on Blank Rule.

Step 7

Add the values in the Edit Inbound Rule window as mentioned in the following screenshots. This rule will redirect all the sites to https from http.

Put {HTTPS} as the condition input and ^OFF$ as the pattern. You can tick the Ignore Case option. Click Ok.

On the Redirect URL, add https://{HTTP_HOST}/{R:1} Click on Apply on the top right corner to apply the rule.

Step 8

Now, when you try to access a http URL, the mod_rewrite feature will detect a HTTP URL and then automatically redirect it to https.

Conclusion

By following the above-mentioned steps, you can successfully enable mod_rewrite feature on IIS.

Check out these top 3 Best web hosting services

Hostinger
$2.99 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
    4.7
  • Support
    4.7
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.7
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Install the WISA (Windows, IIS, SQL, ASP.NET) Stack

WISA is an acronym which stands for (Windows, IIS, SQL, and ASP.net).WISA uses W
3 min read
Vladimir Rakov
Vladimir Rakov
Hosting Expert

How to Deploy IIS and ASP.NET with the Puppet Module

Puppet is a great tool for automating Windows server management, including file
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Migrate A Website From IIS 6 to IIS 7

This guide will teach you to migrate your website from IIS 6 to IIS 7 using the
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How To Harden a Windows IIS Web Server

The article covers how to improve security in Windows Internet Information servi
3 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top