URL Rewriting http to https


I am a novice using the IIS URL rewriting feature, and have little knowledge of regex.

I am looking to create a rule(s) using IIS rewriting that will enforce the use of "https" on appropriate sections of the site, and for the rest of the site enforce the use of "http."

The desired criteria are as follows:

-- If hostname includes "localhost" always use http

-- For URL's that include the strings "login", "admin", or "checkout" enforce use of https. For all other urls, enforce use of http.

Any assistance would be greatly appreciated.
Who is Participating?
Manoj PatilConnect With a Mentor Sr. Software EngineerCommented:
Is it helpful ?
<rule name="Redirect to HTTPS" stopProcessing="true">
  <match url="(.*)" />
    <add input="{HTTPS}" pattern="^OFF$" />
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />

Open in new window

Also try below link
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.