0

I'm using the Flight PHP microframework, and it includes its' own router, and needs the server to rewrite requests to the index.php file.

It features rewrite-rules for both Apache and Nginx but unlucky me, I'm using lighttpd in production, and I'm not really interested in changing that.

So, I hate to be that guy, who just says: Give me the solution.. But seriously, somebody help me, I have no idea how to rewrite Lighttpd requests.

The Apache config is like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

And the Nginx config like this:

server {
    location / {
        try_files $uri $uri/ /index.php;
    }
}

My own Lighttpd config currently looks like this:

$HTTP["host"]  == "zyx.abc.dk"{
        server.document-root = "/var/www/app1/zyx"
        accesslog.filename         = "/var/log/lighttpd/zyx-log.log"
        url.rewrite-once = ( "(.*)" => "/index.php" )
}

But it doesn't work. How can I make the subdomain be rewritten like the above, to make Flight PHP work? I like the framework, so I would be quite sad for having to change it.

Thanks guys! :)

Henrik
  • 103
  • 1

1 Answers1

0
  • your rewrite rule didn't do "QSA" - it deleted the query string
  • your rewrite did trigger for existing files too (not matching !-f and !-d)

The following should keep the query string and only trigger if the requested path is not normal real file (but triggers for directories, which doesn't match the apache !-d - although I'd argue that !-d is probably a bug in the apache config).

url.rewrite-if-not-file = ( "(\?(.*))?" => "/index.php$1" )

You can also use an anchored regular expression:

url.rewrite-if-not-file = ( "^.*(\?(.*))?$" => "/index.php$1" )
Stefan
  • 819
  • 1
  • 7
  • 18