Jump to main content Jump to doc navigation

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.

Enable the URL Rewriting module

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.

Add the rewrites

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"
     )

Important: excluding directories

While this configuration should do teh trick, it's important to realise Lighttpd handles url-rewrites a bit differently.

You must 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 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
  • Jens Wittmann – Gestaltung & Entwicklung
  • deJaya
  • Digital Penguin
  • Following Sea
  • YJ
  • Sepia River Studios
  • Dannevang Digital
  • eydolan
  • Nick Clark
  • Lefthandmedia
  • Murray Wood

Budget

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

Learn more