URL rewriting for wordpress and lighttpd
by Emil Haukeland on Feb.11, 2007, under lighttpd, php, web, wordpress
URL rewriting in lighttpd works somewhat a bit different than in apache web server. Wordpress will not generate those nice URL’s by default and need some help. I googled around for a solution and found a lot of attempts to solve this. It seems like everyone’s trying to make this as difficult as possible. I have tried to make this a bit more simple.
In your lighttpd.conf or 10-rewrite.conf enable mod_rewrite
and then paste the following code (you will need to edit the $HTTP["host"] though):
$HTTP["host"] =~ "emil.haukeland.name" { url.rewrite-final = ( # Exclude some directories from rewriting "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0", # Exclude .php, .html, .gif, .png, .jpg and .txt files at root from rewriting "^/(.*.(php|html|gif|png|jpg|txt)$)" => "$0", # EDIT: Added a $ at the end of the regexp and # excluding of a few more filenames to # solve the problem reported by teko. Thanks! # Handle permalinks and feeds "^/(.*)$" => "/index.php/$1" ) }
These three rules should cover for every plugin and functionality. If you have other folders witch you will need to access without any redirection (images in a separate folder etc), you have to add this to the first rule
Now change the setting in Options->Permalinks to Custom and create your permalink structure. Personally I prefer this:
/%year%/%monthnum%/%day%/%postname%/
I hope this was helpful
14 Comments for this entry
6 Trackbacks / Pingbacks for this entry
-
Lighttpd dan ModRewrite | WordPress [at] mimpikami . com
March 10th, 2008 on 05:20[...] Url rewriting for WordPress and Lighttpd/ [...]
-
Terbaik.Net » Blog Archive » Lighttpd dan ModRewrite
March 17th, 2008 on 11:15[...] Url rewriting for WordPress and Lighttpd [...]
-
wordpress, qTranslate & lighttpd | mriedel.org
January 8th, 2009 on 22:22[...] by hand and are, as opposed to wordpress on apache, not generated automatically by wp. There are some lighttpds mod_rewrite rules on Emil Haukeland’s blog that should do the trick for most [...]
-
URL rewriting for Wordpress and Lighttpd
January 19th, 2009 on 20:03[...] big thanks for saving me a shit-ton of time goes out to Emil Haukeland and his post about configuring lighttpd for wordpress. Lighttpd is a very lightweight open-source web server emphasizing high-performance with low system [...]
-
Lighttpd + PHP + MySQL + eAccelerator = Wordpress on steroids | Les Aventures de Techiemaque...
April 30th, 2009 on 10:12[...] URL rewriting for wordpress and lighttpd [...]
-
Ostebaronen.dk — Mod_rewrite for lighthttpd with Wordpress
October 12th, 2009 on 18:35[...] Many thanks to Emil Haukeland, find the his original blog post on his personal blog: emil.haukeland.name [...]
August 12th, 2008 on 21:30
Thanks dude
That was exactly what I needed!
December 7th, 2008 on 02:17
For some odd reason the code shows up as “=>” and which if copied to lighttpd.conf will result in incorrect syntax. If you get this (I’m using Opera) then replace “=>” with “=>”. Obviously you do all of this without the quotes.
I hope this helps some people.
November 2nd, 2009 on 13:38
This has been fixed
January 3rd, 2009 on 21:29
Thanks a lot for these rewrite rules. I added qTranslate support and am now using them for my own blog.
For anyone wanting wordpress qTranslate lighttpd, check http://mriedel.org/2009/01/03/wordpress-qtranslate-lighttpdwordpress-qtranslate-lighttpd/
February 5th, 2009 on 03:37
Thanks!!! You saved my site. I had tons of broken permalinks, along with other rewrite issues when I moved from Apache to Lighttpd.
February 6th, 2009 on 19:06
Fantastic post!!! Cheers!
June 17th, 2009 on 19:12
I’ve seen about ten different approaches to this problem so far, but http://r00tshell.com/archives/2007/05/16/wordpress-lighttpd-permalinks-without-rewrite/ is the cleverest and simplest, and it looks like it solves other problems as well. Anyone else tried that?
July 11th, 2009 on 02:26
The reason for using URL rewriting is to avoid
http://example.com/index.php?post=/2009/07/11/some-post.
I can’t see how this is solved in the link your mentioning.
July 12th, 2009 on 06:37
very good
To solve the problem of me
thank
October 10th, 2009 on 01:45
Thanks for this.
If you put in “php” to say your blog post (www.test.com/2009/10/10/to-testphpsfdsd/) it will give a 404.
You need to put a dollar sign after php like here:
“^/(.*.php$)” => “$0″,
If you want to exclude multiple files (like .txt, .html) use:
“^/(.*.(txt|html)$)” => “$0″,
November 2nd, 2009 on 13:34
Thanks for this information. The post has been updated
October 14th, 2009 on 10:29
THANKS DUDE!!!!! IT solved everything for me now! all set to customize lighttpd
November 27th, 2009 on 14:00
Thanks a lot! This solved my own problems with Wordpress under lighttpd, after moving from Apache.
Now I only have to find out how to optimalize my setup. I feel that Wordpress is slower in Lighttpd than Apache… I’m experience like 5 seconds of loadingtime before anything shows…
January 30th, 2010 on 07:22
Emil, thanks for the post. Very helpful.