Jump to main content Jump to doc navigation

lighttpd does not use Apache-style .htaccess files. Friendly URL rewrites belong in lighttpd.conf (often /etc/lighttpd/lighttpd.conf on Linux).

This setup is uncommon for MODX hosting. Prefer Apache or nginx when you can. After rewrites work, finish the MODX steps in Using Friendly URLs.

Enable mod_rewrite

  1. Open lighttpd.conf.
  2. Find server.modules.
  3. Ensure mod_rewrite is listed and not commented out.
  4. Reload lighttpd after saving.

Add rewrite rules

Find the host / document-root block for the site, for example:

$SERVER["socket"] == ":80" {
  $HTTP["host"] =~ "example.com" {
    server.document-root = "/var/www/example.com"
    server.name = "example.com"

Add rules under that host so existing files and the assets, manager, core, and connectors trees are not rewritten:

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

Exclude more paths

lighttpd only skips paths you list. To protect another web-accessible directory, extend the first pattern with |dirname, for example (assets|manager|core|connectors|media).

Reload lighttpd, then enable Friendly URLs in the Manager and clear the cache.

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
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

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

Learn more