As some of you have read, I recently switched this production web server over to Lighttpd, and so far I am very much impressed. I have been tinkering with Lighttpd for some time, and I really feel it is a fine replacement for Apache. It supports all the same basic modules that I need (mod_rewrite, mod_alias, mod_auth, etc) and uses far less resources. The only difficulty in switching is migrating the configuration and little “tweaks” to get things setup just right.
One thing, for example, is that WordPress assumes an Apache server, or something that supports .htaccess files. This is not the case with Lighttpd, but is solved very, very simply. Early in my migration I read a number of blog posts suggesting solutions to the WordPress Permalink setup, some more complicated than others. I have to say that I think I found the simplest solution, and it is rarely seen on other blogs. Below is one line that will support any WordPress Permalink setup you want:
## Permalink Support:
server.error-handler-404 = "/index.php"
That’s all there is to it. That one line in the lighttpd.conf will handle the permalinks internally and nothing more is required. No dealing with weird regex patterns and trying to exclude this or that. Lighttpd is smart enough to handle it internally with that line.
If you are using a more complex Permalink rewrite configuration in Lighttpd I’d be interested in hearing if this does or does not achieve the same results.
I just migrated to lighttpd as well. What version or lighttpd are you using? I see that you moved from Slicehost to Linode.. What problems were you having with Slicehost? I moved from Slicehost to Linode and now I’m moving back. I found that Linode’s server, even though I had more RAM, wasn’t able to handle my sites like Slicehost was/is. I would have to reboot my Linode at least once a day to keep my sites up, using the same exact config as what I was using at Slicehost. Now I’m on Lighttpd at Slicehost though, so we will see how that goes for me.
Wouldn’t that send a 404 header with every page request?
@Andrew – At first glance it doesn’t make much sense how/why it works, but it does. This is the only line of code re: URL rewriting I have on this blog but as you can tell all the URL seem to be working just fine.
It does “work” in the sense that it gets the URL redirects to work. But as Andrew mentioned, probably not a good idea to return HTTP status 404 (indicating that the content could not be found) for every single page on your blog.
@Joseph – that’s the thing though. It isn’t displaying a 404 error for every single page on the blog. If you were able to see this page, and comment on it, I’m assuming you got more than a 404 error.
Just check…it’s returning 200 OK.
You have got something 404ing from google though Christer.
Yes, that’s a clever approach and I’ve been using it for a while with b2evolution, too.
But, you’ll lose the PATH_INFO information, e.g. from http://example.com/index.php/PATH_INFO
You may grep WP’s source for PATH_INFO, to see if it gets used anywhere.
I’m currently using a magnet/LUA script.
See also http://daniel.hahler.de/clean-urls-with-lighttpd
“If you were able to see this page, and comment on it, I’m assuming you got more than a 404 error.”
That doesn’t mean that your server isn’t sending back a 404 status code in the header. I did check, and I am getting back 200 OK, but I would be worried that future LightHTTP versions send back 404 headers with your settings and it would absolutely kill your SEO.
…thank you for this great solution and it works for me, 🙂
really usefuyl to me,thanx alot!
Quick and dirty.
Clean solution including multi-wordpress support isn’t so much more work: http://www.chrische.de/2010/04/lighttpd-in-verbindung-mit-wordpress-und-rewrites/
works perfectly. Thank you.
I do like the quick and dirty way of getting things done as long as it just works.