How to force HTTPS from web.config file?

The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find. You can use the URL Rewrite module to perform URL manipulation tasks. To use this rule below are the prerequisites.

1. IIS 7 or above with ASP.NET role service enabled.
2. URL Rewrite Module installed.

Click here for more information on the Rewrite Module.

When you want to force HTTP to HTTPS, you will need to add below code in your web.config file.

<system.webServer> <rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>

 

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How much experience do you have with .Net Application Hosting?

Our most staff members are Computer Graduates or Masters in computers. Most of them have 5+ years...

How to place classic windows VPS order?

This is a video tutorial about selecting an appropriate configuration for your Classic Windows...

How much RAM do I need for the smooth execution of my Windows VPS services?

This video will help you to choose the correct RAM resource to smoothly execute your services.

Does your Windows Hosting plan support ASP.NET MVC 5?

Yes, our Windows shared hosting plans do support ASP.NET MVC 5. Please refer our Windows Shared...

Recommended open ports in Windows Firewall of your VPS

Following is the list of recommended open ports in Firewall of your VPS: Make sure that the...