WordPress on IIS – How to Force HTTPS Redirection and Use Permalinks

httpsiispermalinksrewriteWordpress

Currently, I have a WordPress site which is running under IIS 10. I use custom permalinks and I use the following URL Rewrite rule to make my permalinks work.

IIS URL Rewrite Screenshot

The problem is, HTTPS redirection isn't working. By that I mean if I navigate my browser to http://example.com, it doesn't direct automatically to https://example.com.

So, how can I add a dual-rule which will do both these tasks I want without causing problem such as broken permanlinks?

Thanks.

Best Answer

You need to create a second rule for the HTTPS redirect. Place it above your permalink rule so it gets parsed first.

Match URL

Requested URL: Matches the Pattern

Using: Regular Expressions

Pattern: (.*)

Ignore Case

Conditions

Match All

Input: {HTTPS}

Type: Matches the Pattern

Pattern: ^OFF$

Action

Action Type: Redirect

Action Properties

Redirect URL: https://{HTTP_HOST}/{R:1}

Append Query String

Redirect type: 301, 302, or 303

HTTPS Redirect_1 HTTPS Redirect_2