Project

General

Profile

[Solved] rewrite-if-not-file resulting in 404 not found (reported from Lighttpd not framework)

Added by mattk over 1 year ago

I am attempting to get a rewrite rule working for use by the Slim PHP framework.

The framework suggests to use the following config:

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

As I wanted my API to be on a different port, I'm using the following configuration:

$SERVER["socket"] == "0.0.0.0:6549" {
     ssl.engine                  = "enable" 
     ssl.cipher-list             = "aRSA+HIGH !3DES +kEDH +kRSA !kSRP !kPSK" 
     ssl.pemfile                 = "/mnt/kd/ssl/webinterface.pem" 
     ssl.ca-file                 = "/mnt/kd/ssl/https_ca_chain.pem" 
     server.document-root        = "/var/www/api/public" 
     accesslog.filename          = "/var/log/lighttpd/ssl-access.log" 
     url.rewrite-if-not-file     = ("(.*)" => "/index.php/$0")
     url.access-deny             = ( "~", ".inc", ".htpasswd", ".htaccess" )
     dir-listing.activate        = "disable" 
}

Accessing https://serverurl.com:6549/ or https://serverurl.com:6549/index.php works, though when I try https://serverurl.com:6549/hi it comes up with a 404 not found. I can confirm this is not reported from Slim PHP as I set index.php to only contain the following and the same issue occured:

<?php
echo "TEST";


Replies (2)

RE: rewrite-if-not-file resulting in 404 not found (reported from Lighttpd not framework) - Added by gstrauss over 1 year ago

Please see How to get support and follow the instructions about testing your config. You have not shared your entire config, and your problem is possibly elsewhere, such as not loading "mod_rewrite" in server.modules in lighttpd.conf.

Separately, you might also want to review lighttpd TLS docs to update your TLS config. In modern lighttpd.conf, you should prefer to use lighttpd defaults instead of specifying ssl.cipher-list and you should include the certificate chain in the ssl.pemfile. ssl.ca-file has been renamed to ssl.verifyclient.ca-file to indicate its proper use with client certificate verification, and that is not how you are using it.

RE: rewrite-if-not-file resulting in 404 not found (reported from Lighttpd not framework) - Added by mattk over 1 year ago

Yep, it ended up being that I didn't add the `"mod_rewrite"` to `server.modules`.
Sorry about that and thanks for your help.

    (1-2/2)