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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Apache Spark 3 to Apache Spark 4 Migration: What Breaks, What Improves, What's Mandatory
  • All About GPU Threads, Warps, and Wavefronts
  • DataWeave: Play With Dates (Part 1)
  • Tired of Messy Code? Master the Art of Writing Clean Codebases

Trending

  • When One MVP Is Really Four Systems: A Better Way to Plan Multi-Role Apps
  • 5 Common Security Pitfalls in Serverless Architectures
  • Why DDoS Protection Is an Architectural Decision for Developers
  • Why Round-Robin Won't Save You: Load Balancing Challenges in Data Streaming Services With Heterogeneous Traffic
  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.

By 
S.Prakash Chowdhry user avatar
S.Prakash Chowdhry
·
Oct. 14, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
31.1K 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.

Related

  • Apache Spark 3 to Apache Spark 4 Migration: What Breaks, What Improves, What's Mandatory
  • All About GPU Threads, Warps, and Wavefronts
  • DataWeave: Play With Dates (Part 1)
  • Tired of Messy Code? Master the Art of Writing Clean Codebases

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook