• Document Up to Date
  • Updated On 4.0.0

Configuring URL Rewriting

URL rewriting turns hard to remember, long and complicated URLs into easier to remember URLs. Simple URL rewrite rules per site can be done through Crafter Engine.

CrafterCMS comes with the Tuckey URLRewrite filter, a Java Web Filter with functionality like Apache’s mod_rewrite, that lets you setup rewrite rules for your site.

To add a URL rewrite rule, in Studio, open the Sidebar then click on projectTools. Click on Configuration then select Engine URL Rewrite Configuration (XML Style).

Configurations - Open URL Rewrite Configuration

Below is a sample URL rewrite configuration.

 1<?xml version="1.0" encoding="utf-8"?>
 3<!DOCTYPE urlrewrite
 4        PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
 5        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
 9    <rule>
10        <from>^/some/olddir/(.*)$</from>
11        <to type="redirect">/very/newdir/$1</to>
12    </rule>
14    <rule match-type="wildcard">
15        <from>/blog/archive/**</from>
16        <to type="redirect">/roller/history/$1</to>
17    </rule>

After saving the configuration, remember to publish the configuration file just saved (urlrewrite.xml file). To publish the configuration file, from the Sidebar, click on Dashboard. In the My Recent Activity dashlet, check the box next to the urlrewrite.xml file, and click Publish from the context nav to publish.

Configurations - Publish URL Rewrite Config File from Dashboard

For more information on the UrlRewriteFilter, see http://tuckey.org/urlrewrite/