0
I want to have a directory on my lighttpd server that will redirect all requests to a main index.php
file, but with the PHP to be able to interpret the original request URI.
For example, both www.server.com/directory/foo
and www.server.com/directory/bar
would run www.server.com/directory/index.php
, but the PHP context would be able to see the domain (with something like $_SERVER['uri']
?) and use an internal PHP router to figure out what to do.
Currently I've tried a few variations on this:
$HTTP["url"] =~ "^/directory/.*" {
url.redirect = (
"^/.*/assets/(.*)" => "/dir/assets/$1",
"^/.*/(.*)" => "/dir/index.php"
)
}
but the index.php
is unable to see the original route. The assets thing works though. Thanks!
I do it on apache2 by redirecting to the PHP script if a file or directory matching the request isn't found. This kicks in before a 404 is sent to the client, so it is transparent on that end. – ivanivan – 2019-09-14T22:27:02.497