Jump to main content Jump to doc navigation

Lighttpd Guide for Setup and Friendly URLs

  • This is still a work in progress, and currently only covers the URL rewriting aspect.
  • This guide assumes you already have a working lighttpd, mysql, and PHP installation.
  • This guide only covers proper settings and the use of friendly URL Rewriting.

Friendly URL Setup

lighttpd does not use the same system, or even same idea as Apache does for URL rewriting. All URL rewriting is done in the lighttpd.conf file

First we need to make sure that the URL rewriting module is enabled.

  • So open your lighttpd.conf config file (In Linux it is usually located in /etc/lighttpd/lighttpd.conf)
  • Look for the directive server.modules.
  • Under this directive, look for an entry named mod_rewrite,.
  • By default it has a # in front of it. This is a comment symbol. Please remove the # from the line and save the file.

Next we need to find the location in which to put the friendly URL code. So lets search for something that looks like this:

$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "yourdomainname.com" {
    server.document-root = "/path/to/your/doc/root"
    server.name = "yourservername"

Directly under this you should add the following code.

    url.rewrite-once = ( "^/(assets|manager|core|connectors)(.*)$" => "/$1/$2",
           "^/(?!index(?:-ajax)?\.php)(.*)\?(.*)$" => "/index.php?q=$1&$2",
           "^/(?!index(?:-ajax)?\.php)(.*)$" => "/index.php?q=$1"
     )

This does not mean you are done! Lighttpd handles url-rewrites a bit differently.

You HAVE to exclude any files or folders you do not want rewritten in the config file. Excluded dirs/files in the example above are (assets|manager|core|connectors). If you wish to add more to these, simple add another | followed by the folder or filename you wish to omit from url rewriting.

After this is done, you will have working friendly URLs again in lighttpd.

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Lefthandmedia
  • Murray Wood
  • eydolan
  • Following Sea
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$301 per month—let's make that $500!

Learn more