Lighttpd and wordpress setup clean SEO friendly URLs

By default WordPress uses web URIs which have question marks and lots of numbers in them; however WordPress offers you the ability to create a custom URI structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links.

Apache has .htaccess file to setup clean SEO friendly URLs using mod_rewrite module. Similarly. Lighttpd can be use mod_rewrite for writing out clean SEO friendly URLs.

Task: Single wordpress blog (documentroot) and SEO URLS

Let us assume that your blog is hosted at (i.e. no subdirectory) and your want pretty urls.

=> Login to your wordpress admin account

=> Go to Options > PermaLinks

=> Now select URL structure as per your need.
For example Date and name based Permalink Structure should be set as follows (remove the default /index.php/%year%/%monthnum%/%day%/%postname%/):

=> Click on Update Permalink structure button to save the changes.

=> Now open your lighttpd configuration file
# vi /etc/lighttpd/lighttpd.conf

=> Locate your virtual hosting configuration for your domain ( and aftter server.document-root add following line:
server.error-handler-404 = "/index.php?error=404"

At the end your configuration should look as follows:
$SERVER["socket"] == "203.xx.xx.xx:80" {
server.document-root = "/home/lighttpd/"
server.errorlog = "/var/log/lighttpd/"
accesslog.filename = "/var/log/lighttpd/"
server.error-handler-404 = "/index.php?error=404"

Save and close the file. Restart lighttpd:
# /etc/init.d/lighttpd

Task: Multiple wordpress blogs single documentroot and SEO URLS

Let us assume that you have multiple blogs hosted under single document root called /home/lighttpd/ as follows:
/home/lighttpd/blog1 (
/home/lighttpd/blog2 (


First, Login to both blogs and setup Permalink structure as per your requirements. Open /etc/lighttpd/lighttpd.conf file:
# vi /etc/lighttpd/lighttpd.conf

Find your domains configuration section and append lines as follows:
$HTTP["url"] =~ "^/blog1($|/)" { server.error-handler-404 = "/blog1/index.php?error=404" }
$HTTP["url"] =~ "^/blog2($|/)" { server.error-handler-404 = "/blog2/index.php?error=404" }

Save and close the file. Restart lighttpd:
# /etc/init.d/lighttpd restart

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 12 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
12 comments… add one
  • ali Apr 12, 2007 @ 12:39

    It was really surprising to see that the only necessary step to take was to address the 404, definitely much easier than Apache 🙂

    Thank you for the tip.

  • BOK Apr 29, 2008 @ 19:14

    Indeed amazingly simple!
    I spent an hour or more on multiple line configs while this was all that was needed… Thanks!

  • 🐧 nixCraft Apr 29, 2008 @ 23:18

    Please make sure you have 404.php in template directory to send 404 stats when you got actual error 404.

  • Rick May 24, 2009 @ 3:05

    Very userful!

  • rbtok Jul 1, 2009 @ 19:28

    finally i found the simplest and useful way to solve this problem

    thanks pal!

  • Calvin Sep 17, 2009 @ 19:27

    I had spent hours trying to get the permalinks working, this did the job in under 2 minutes.

    Thanks so much 🙂


  • @sinergepress Nov 29, 2009 @ 9:50

    Thanks, solved the problem pretty neatly! Cheers

  • This Jan 6, 2010 @ 18:16

    As a webdesigner myself , I’m extremely glad to see that another individual thought to post this topic.

    Quite a few people out there just don’t grasp the concept of what all is needed in this industry, and I think also we are many times underrated
    or taken for granted. Never the less I’m immensely glad to see that you may feel the same way I do , thanks so much for your blog!

  • Miguel Jun 30, 2011 @ 21:55

    thank you very much, i TRIED others tutos before for multiple blogs and didnt worked for me, your in forst try get up and running

  • fred Nov 22, 2012 @ 16:21

    Thank You! This worked for me after hours of searching and trial and error with rewrite rules. Beautifully simple!

  • Carl Jul 29, 2013 @ 19:30

    This worked for me on latest wordpress:

    server.error-handler-404 = “/index.php”

  • Fernando Oct 30, 2015 @ 12:47

    Excellent, you save my day! 🙂
    Thank you!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum