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.
Crafter CMS 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.
Below is a sample URL rewrite configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd"> <urlrewrite> <rule> <from>^/some/olddir/(.*)$</from> <to type="redirect">/very/newdir/$1</to> </rule> <rule match-type="wildcard"> <from>/blog/archive/**</from> <to type="redirect">/roller/history/$1</to> </rule> </urlrewrite>
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 widget, check the box next to the
urlrewrite.xml file, and click Approve & Publish from the context nav to publish.
For more information on the UrlRewriteFilter, see http://tuckey.org/urlrewrite/