Andrés Villenas Blog

Passion for programming

URL Rewrite Module for Sitecore, part 2

This post is a second part about the URL Rewrite Module that I described in a previous post URL Rewrite Module for Sitecore, part 1. This post will cover the creation of some useful inbound rules

Inbound rules creation

As we mentioned in the previous post, inbound rules allow setting a regular expression to match on the path of a URL that will be handled rewrite module.

For instance, let's create an inbound rule to route the requests that come from the insecure HTTP and use the HTTPS protocol.

1. Create an Inbound Rule

2. To match all the requests, use Regular Expressions in the Using field and set the Pattern field with the value (.*)

3. Now, we have to filter the requests that are not using the HTTPS protocol. For this, we need to create a condition.

4. To know if the request is missing the HTTPS protocol, use the Condition Input Type {HTTPS} and the pattern 'off' that will check if it is missing.

5. Now, we need to create an action that will be triggered if the condition is met. 

6. The redirect action should rewrite the URL so it uses the HTTPS protocol instead of HTTP.

Once, all these items were created and published, Sitecore is going to redirect the HTTP request to HTTPS.

That's it for today.

Until the next post!