Fork me on GitHub

Using the URL Rewriter

Overview

In the CMS, in the document section there should be an extra harmonica called 'URL Rewriter'. When you click one of folders you will see an overview of the rules with some extra information like the from, to and type of redirect. Note that this does not display the conditions, or even if there are any. The rules will be processed in the order they appear, so keep this in mind when creating rules of different depth. For example, the rule rewriting /abc should come after the rule rewriting /abc/def.

Which rules and conditions have been configured and in what order they will be processed can be seen on the status page. By default /rewrite-status, but only accessible locally.

Configuration

On the rulesLocation node (default: /content/urlrewriter) you can set some properties which will affect all rules.

Property Explanation default
urlrewriter:ignorecontextpath setting this to false will require you to prefix all the URLs you want to match with the contextpath, use this if you don't strip the context path from your URLs true
urlrewriter:usequerystring when set to true, the query string is taken into account when matching URLs false
urlrewriter:skippedprefixes (since 1.04.01) this is a multiple string, each value is a prefix that should not be rewritten {/_cmsinternal, /_cmsrest, /_rp, /hn:, /ping/ (since 1.05.05)}
urlrewriter:skippost (since 1.04.01) when set to true, POST requests will not be rewritten true

Adding Rules

When creating a new rule, there are three options:

Rule Type Explanation
Rule This type is the most simple to use, and should cover all the common use cases
Advanced Rule This type supports conditional rewrites and is regular expression based. It should be able to cover almost any use case.
XML Rule Here you can add XML Rules in the format supported by the underlying software, Paul Tuckey's Url Rewrite Filter