Lighttpd: Enabling module rewrite for Drupal

drupallighttpdmod-rewrite

I'm configuring lighttpd (1.4.26) for drupal on Ubuntu 10 and I've some issues with the rewrite module.

So far I have enabled the rewrite module in lighttpd.conf

Then, I have added the following lines to the configuration file (as written here http://drupal.org/node/43782).

url.rewrite-final = (
  "^/system/test/(.*)$" => "/index.php?q=system/test/$1",
  "^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",
  "^/([^.?]*)$" => "/index.php?q=$1",
   "^/rss.xml" => "/index.php?q=rss.xml"
)

But What I get is "page not found" for any URL on my server

I also have another question: are there directory-level configuration file with lighttpd, or should I exclusively work with lighttpd.conf ?

thanks

Update
I found out I can use a LUA script, but I'm afraid my lighttpd version is not compiled with the mod_magnet module, since I don't see it in the modules list in the configuration file.

$HTTP["host"] == "host.com" {
  server.document-root = "/path/to/drupal/site/"
  dir-listing.activate = "disable"
  magnet.attract-physical-path-to = ("/etc/lighttpd/drupal.lua")
}

Best Answer

I just setup up drupal on my webserver , just for you ;) Here is an example config-snippet with vhost:

$HTTP["host"] =~ "drupal\.mysite\.com$" {
        server.document-root = "/var/www/drupal/"
        url.rewrite-final = (
                "^/system/test/(.*)$" => "/index.php?q=system/test/$1",
                "^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",
                "^/([^.?]*)$" => "/index.php?q=$1",
                "^/rss.xml" => "/index.php?q=rss.xml"
        )
}

That works (i can enable Clean URLs in drupal and it seems to work), i don't know how your config looks actually, but maybe first try to adapt my one. You have to put this at the end of your lighttpd.conf The LUA stuff should also work, all roads lead to Rome ;) But I think it's better to keep it simple and not to enable so much modules. I'm sure you'll need the rewrite module more than magnet in the future.

Related Topic