Search Engine Friendly URL's with ModX and Lighttpd
Although I prefer Ruby/Rails cms/blog systems like Radiant CMS, I sometimes have to live with php based solutions. I found a rather good CMS system called ModX with has all kind of Ajax bells and whistles and is very flexible. But like many other PHP based solutions it requires url rewriting to let it work with search engine friendly url’s. Out of the box it has a .htaccess to let it work with Apache. The following snippet describes how to setup the rewriting rules for lighttpd:
- Enable mod_rewrite module
- Enable the “mod_rewrite” module in the lighttpd.conf file.
- Add a rewrite rule
- Add the following rewrite rule in the lighttpd.conf file
url.rewrite-once = ( "^(.*).html$" => "/index.php?q=$1")
- Restart lighttpd
- Enable SEF urls
- Enable search engine friendly urls in the modX manager, the friendly url settings “Use friendly URLs”, “Use friendly aliases”, “Use friendly alias path” all work as expected.
Note: There seems to be one minor issue with the mod_rewrite module of Lighttpd and that is that if you have a alias with more then two hyphen characters will fail while one or two works perfectly. I’m very interested to hear how I can fix this.
Update: 9/12/2006I found a japanese website which suggested the following rewrite rule, I don’t have the possibility now to test this rule but maybe you can leave a comment if it works:
url.rewrite-once = ( "^/(assets|manager)/(.*)$" => "/$1/$2",
"^/(.*)?(.*)$" => "/index.php?q=$1&$2",
"^/(.*)$" => "/index.php?q=$1",
)
Posted by Administrator on Friday, December 01, 2006

