DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. How to Set Up HTTP/HTTPS Redirection in IIS

How to Set Up HTTP/HTTPS Redirection in IIS

Want to learn more about how to set up HTTP and HTTPS? Check out this tutorial on setting up HTTP and HTTPS redirection in IIS.

S.Prakash Chowdhry user avatar by
S.Prakash Chowdhry
·
Oct. 14, 18 · Tutorial
Like (2)
Save
Tweet
Share
29.52K Views

Join the DZone community and get the full member experience.

Join For Free

Before you can set out with an HTTP/HTTPS redirect in IIS, you’ll need to make sure that you have an SSL certificate already installed. This is not a step you can skip. Once you’ve got the certificate installed, we can start working on a URL rewrite to redirect your traffic to your new-fangled HTTPS site.

Let’s Get Started

1. Download and install the IIS URL Rewrite Module

2. Open IIS Manager and, in the console, select the website you want to redirect

3. Select URL Rewrite

4. Click Add Rules

5. Select Blank Rule, click OK

6. Enter the Name of rule

7. In the Match URL section, choose “Matches the Pattern” in the Requested URL drop-down

8. Next, select “Regular Expressions” in the Using drop-down

9. In the Match URL section, enter: “(.*)”

10. In the conditions section, select Match All under Logical Grouping, then click Add

11. In the next window:

  • Enter {HTTPS} as the condition input
  • Select “Matches and Pattern” from the drop-down
  • Enter ^OFF$ as the pattern
  • Click OK

12. In the Action section, click Redirect and then specify the Redirect URL as https://{HTTP_HOST}/{R:1}

13. Check the Append Query String box

14. Choose your redirection type (301)

15. Click Apply

Apply the Rule to Your Website

1. In the IIS dashboard, right click on your site and select Explore

2. Your Root Directory will open — select the web.config file and open it

3. Make sure the file contains the following code block (if not, add it):

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”HTTPS force” enabled=”true” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>


4. If you have a web.config file in your root directory, create a new .txt file and place the above code in it, save and then rename the file to web.config.

Hope this helps!

Rewrite (programming) Directory Console (video game CLI) Blank (solution) Strings Blocks Data Types HTTPS

Published at DZone with permission of S.Prakash Chowdhry. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Asynchronous HTTP Requests With RxJava
  • Hidden Classes in Java 15
  • Remote Debugging Dangers and Pitfalls
  • Taming Cloud Costs With Infracost

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: