Quick tip: Rewrite Rules for WordPress
We use WordPress for this blog and I recently upgraded to the 2.7.1 version. The developers have started using a .htaccess file with Apache mod_rewrite rules, so we need to emulate that to support certain things like permalinks. This is a quick and trivial example, but it gives a glimpse at our new rewrite dispatch syntax in Resin 4.
| WordPress .htaccess | Translated into Resin 4 rewrite dispatch |
|---|---|
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
|
<web-app xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin">
<resin:Dispatch>
<resin:IfFileExists/>
</resin:Dispatch>
<resin:Forward regexp="^" target='/index.php'/>
</web-app>
|
I find our syntax to be far more readable and understandable than mod_rewrite, though that’s not hard.
Notice that the rules don’t have to be enclosed in <rewrite-dispatch> tag as in 3.1 — they’re first class members in the configuration. In case you have old rewrite dispatch rules from 3.1, Resin 4 does still understand them for backwards compatibility.

November 16th, 2009 at 5:17 am
Excellent! I was wondering if permalinks was possible. Unfortunately, looks like GD is broken in 4.0? WordPress’s insert photo features won’t enable thumbnail, medium, large sizes -possibly because they rely on GD functions. It appears that a simple GD text to image render PHP script crashes on 4.01, but was okay on 3.1. Outside of that, WP on Resin is looking really good!
November 16th, 2009 at 4:38 pm
Hi Steveorevo,
Permalinks should work fine. Actually, caucho.com runs on WordPress and uses permalinks for the navigation.
Do you have an example of GD functions failing? This blog runs on WP and Quercus and I’m able to post images just fine.
Thanks,
Emil