Дружественные URL MODX в lighttpd



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

Actually there can be assets for which you want to execute php (such as the tinymce php files). So you either need to exclude more paths above, which quickly gets ugly, or move to a lua mod_magnet solution for 1.4.13. lighty config:

$HTTP["url"] !~ "/(?:manager)" {
    magnet.attract-physical-path-to = ( "/etc/lighttpd/modx.lua" )
}

modx.lua:

attr = lighty.stat(lighty.env["physical.path"])
if (not attr) then
   path = "/index.php"
   uri = string.sub(lighty.env["request.uri"],2)
   lighty.env["uri.query"] = "q=" .. uri
   lighty.env["uri.path"] = path
   lighty.env["request.uri"] = path .. "?" .. lighty.env["uri.query"]
   lighty.env["physical.rel-path"] = path
   lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. path
end  

That lua script essentially does the same thing as the apache mod_rewrite and htaccess code included in the distribution.