Mapping different URLs to one PHP script
Posted: Tue Jul 03, 2007 10:05 am
I have a web site which uses PHP code to check for a cookie set by our corporate authentication server, and look up the account in an ACL in my database. Among other things, I need to make sure a customer cannot see other customer’s data.
Now, I have been given customer specific reports, in HTML and possibly binary formats, which of course do not have my PHP code to check the authentication and authorization. I would like to write a single PHP file, and have all requests under a certain directory to be processed by that PHP file, which could then try to figure out the relative file path from the original URL and serve the file only if authorization passes.
So, if the URI is /report/customer-C/report-R/index.html, then instead of having this report in a sub-directory of the web-folder, the URL would be processed by get-report.php, which would check authorization, and get the file from a directory not accessible from the web-folder (i.e. not in a sub-directory).
I am using:
Windows Server 2003
Apache HTTP Server 2.2.3
PHP 5.1.4 (cgi-fcgi)
Now, I have been given customer specific reports, in HTML and possibly binary formats, which of course do not have my PHP code to check the authentication and authorization. I would like to write a single PHP file, and have all requests under a certain directory to be processed by that PHP file, which could then try to figure out the relative file path from the original URL and serve the file only if authorization passes.
So, if the URI is /report/customer-C/report-R/index.html, then instead of having this report in a sub-directory of the web-folder, the URL would be processed by get-report.php, which would check authorization, and get the file from a directory not accessible from the web-folder (i.e. not in a sub-directory).
I am using:
Windows Server 2003
Apache HTTP Server 2.2.3
PHP 5.1.4 (cgi-fcgi)