Forum

Send the complete filesystem path of the requested file to cgi

Marius Dinu
22 September 2015, 12:37
Hi.

There is no CGI variable that shows the real (filesystem) path for aliased dirs when an error handler is used.
For example, in case of a 404 error handler, DOCUMENT_ROOT and REQUEST_URI cannot be used to locate the path where the file was not found, and SCRIPT_FILENAME will point to the location of error handler, not the missing file.
A variable that shows the filesystem path for the requested file is needed - the path where the server looked for the requested file or directory before redirecting to start file, directory index or error handler.

OR

Allow SetEnv in Directory sections too, so we can send the required path manually for each aliased dir.

Thank you!
Hugo Leisink
22 September 2015, 14:52
Feature request accepted and already implemented. In the next version, the alias will be available in the environment variables ALIAS_FROM and ALIAS_TO. If you then remove the ALIAS_FROM part from the REQUEST_URI and place what's left over after ALIAS_TO, you'll have the full path to the requested file on disk.

Example:
Alias = /foo:/bar
URL: http://example.com/foo/file.txt

REQUEST_URI: /foo/file.txt
ALIAS_FROM: /foo
ALIAS_TO: /bar

Remove '/foo' from '/foo/file.txt'. What's left over: '/file.txt'. Place after '/bar' to get '/bar/file.txt'.
Marius Dinu
25 September 2015, 06:17
How fast!
But why not REQUEST_PATH=/bar/file.txt ?
Hugo Leisink
28 September 2015, 16:15
Because this was easier to do.
This topic has been closed.