Simplest WordPress Permalink Solution for Lighttpd

By | 2009/02/23

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.

12 thoughts on “Simplest WordPress Permalink Solution for Lighttpd

  1. Chris

    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.

    Reply
    1. Christer Edwards Post author

      @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.

      Reply
  2. Joseph Scott

    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.

    Reply
    1. Christer Edwards Post author

      @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.

      Reply
  3. Dean

    Just check…it’s returning 200 OK.

    You have got something 404ing from google though Christer.

    Reply
  4. Andrew

    “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.

    Reply
  5. tw

    works perfectly. Thank you.

    I do like the quick and dirty way of getting things done as long as it just works.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *