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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Zero Trust for Agents: A New Lens to Secure Agents
  • Replacing JSON With Protobuf in Your Microservice Mesh: A Zero-Downtime Migration Blueprint
  • Apache Spark 3 to Apache Spark 4 Migration: What Breaks, What Improves, What's Mandatory
  • All About GPU Threads, Warps, and Wavefronts

Trending

  • Age Verification Is Becoming One of Tech’s Hardest QA Problems
  • Vapi vs Retell AI vs LiveKit: Architecture, Latency, Pricing, and Developer Experience
  • What Actually Costs You in a Production DevOps System
  • As AI Agents Multiply, Repository Access Could Become an Infrastructure Problem

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Oct. 14, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
31.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • Zero Trust for Agents: A New Lens to Secure Agents
  • Replacing JSON With Protobuf in Your Microservice Mesh: A Zero-Downtime Migration Blueprint
  • Apache Spark 3 to Apache Spark 4 Migration: What Breaks, What Improves, What's Mandatory
  • All About GPU Threads, Warps, and Wavefronts

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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