lighttpd forum migration > Apache RewriteCond to Lighttpd

Posted by Miloslav Kmet
on 28.09.2007 14:25
Hello. I am new to Lighttpd and its configuration. I want to migrate 
some sites running on apache to Lighttpd to improve the performance of 
my server but I get into troubles with simple apache mod_rewrite rules 
in .htaccess.

I have following .htaccess file for Apache:

ErrorDocument 403 /index.php?do=/public/error/403/
ErrorDocument 404 /index.php?do=/public/error/404/

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/file/.*
RewriteCond %{REQUEST_URI} !^/install/.*
RewriteCond %{REQUEST_URI} !^/design/.*
RewriteCond %{REQUEST_URI} !^/plugins/.*
RewriteRule ^index.php(/.*)$ /index.php?do=$1 [L]

RewriteCond %{REQUEST_URI} !^/file/.*
RewriteCond %{REQUEST_URI} !^/install/.*
RewriteCond %{REQUEST_URI} !^/design/.*
RewriteCond %{REQUEST_URI} !^/plugins/.*
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} !^/robots.txt
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteRule ^(.*)$ /index.php?do=/$1 [L]

So I try this configuration in my lighttpd.conf:
$HTTP["host"] == "my.host" {
    $HTTP["url"] !~ 
"^/(file|install|design|plugins|robots\.txt|\favicon\.ico)" {
        url.rewrite-once = (
            "index.php(/.*)$" => "/index.php?do=$1",
            "^(.*)$" => "/index.php?do=$1"
        )
    }
}

But on http://my.host/login/ I got a 404 error.

So I tried to comment the first condition $HTTP["url"] !~ ... and the 
rewriting seems to work fine. What should I have incorrect in that 
condition?

I am using Lighttpd lighttpd-1.4.13 from Debian Stable.

Thank you.