Apache Rewrite rules to replace wildcard based url translation in eZ Publish 3.10.0

Wildcard based URL translation has been removed in eZ Publish 3.10.0. In the upgrading from eZ Publish 3.9.x to 3.10.0 documentation on eZ.no, we can now read (I think this note was not there when I upgrade at the beginning of October…):

Before continuing, note that eZ Publish 3.10.0 does not support wildcard based URL forwarding anymore. This possibility was removed when implementing the multilingual URLs functionality. However, it might be added in the future (refer to changelogs and latest release announcements for more information).

Wildcard based URL translation is (was…) a very easy to use way to install a kind of simple rewriting rules on a site from eZ Publish almost without technical knowlegde. I use this feature to shorten long URLs when using the layout module for specific RSS feeds for instance.

Wildcard rules are still in the database, so I wrote a small script that transforms eZ Publish wildcard rules into apache rewrite rules. You can download the script, you just have to run it from eZ Publish root directory. For me, it generates something like:

#### Auto-generated rules ####
## you may need to load mod_rewrite
## you may need to uncomment the following line
# RewriteEngine on
### Direct rules
## for those rules, you need to load mod_proxy
# eZ Publish rss/feed/tag/* -> layout/set/rss/content/view/rsspost/{1}
RewriteRule rss/feed/tag/(.*) layout/set/rss/content/view/rsspost/$1 [P,L]
# eZ Publish rss/feed/commentaires/* -> layout/set/rss/content/view/rssco/{1}
RewriteRule rss/feed/commentaires/(.*) layout/set/rss/content/view/rssco/$1 [P,L]
# eZ Publish rss/feed/trackback/* -> layout/set/rss/content/view/rsstb/{1}
RewriteRule rss/feed/commentaires/(.*) layout/set/rss/content/view/rsstb/$1 [P,L]

You can put the generated code in the apache configuration, but you'll probably have to tweak rewrite rules. Of course mod_rewrite has to be loaded in apache (you already have it in a Virtual host setup) and for direct rules (kind of alias without redirect) you also need mod_proxy to be loaded. As I use apache 1.3 under Ubuntu, I run these commands as root :

$ sudo apache-modconf apache enable libproxy
Replacing config file /etc/apache/modules.conf with new version
$ sudo /etc/init.d/apache reload