• About this blog

    This blog features updates, opinions, and technical notes from Caucho engineers about Caucho products, the enterprise Java industry, and PHP. Caucho Technology is the creator of the Resin Application Server and the Quercus PHP in Java engine. A leader in Java performance since 1998, Caucho is a Sun JavaEE licensee with over 9000 customers worldwide.
  • Follow Caucho on Twitter

    • Tell us your thoughts about using IDEs with Resin: http://forum.caucho.com/showthread.php?t=16022 2010/08/26
    • Wondering if a CDI-based alternative to grails/roo has appeared. A groovy/CDI framework would be interesting. 2010/08/24
    • By open source experience, I mean contributions 2010/08/17
  • Tags

    ajaxworld apache bam candi cdi cloud cluster comet deploy devoxx eclipse embedded facebook flash flex google app engine hessian hmtp ioc javaone javazone jms marakana messaging mule newsletter nyjug osgi php pomegranate quercus resin resin 4.0 REST servlet sfjug silicon valley code camp training tssjs watchdog webbeans web profile websockets wordcamp wordpress
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
« Quercus on the Google App Engine
Resin 4.0.0 Release »

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.

Tags: quercus, resin 4.0, wordpress

This entry was posted on Monday, May 4th, 2009 at 1:51 pm and is filed under Engineering. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “Quick tip: Rewrite Rules for WordPress”

  1. Steveorevo Says:
    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!

  2. Emil Says:
    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

Leave a Reply

You must be logged in to post a comment.


Caucho Technology is proudly powered by WordPress and Quercus®
Entries (RSS) and Comments (RSS).