Forum Moderators: phranque
http://example.net/dir1/services/
http://example.net/dir1/services
The first link will return the following (relevant) headers:
HTTP/1.x 200 OK
... whereas a request for the filename itself returns the following (relevant) headers:
HTTP/1.x 200 OK
Content-Location: services.php
Vary: negotiate
TCN: choice
Note the "Content-Location" header in particular. It's not that big of a deal, but let's say I didn't want the actual document name plus extension being leaked, how would I go about it? Any ideas? Direction? Cares, concerns?
Something like:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(([^/]+/)*[^/.]+/?)$ /$1.php [L]
Content-Location header using mod_headers [httpd.apache.org] without affecting the underlying negotiation process. From the documentation, I first tried the following:
Header unset Content-Location However this did not work as expected whatever I tried. Then I remember the negotiation process, and how the server handles a request when it is unable to decide the most appropriate file to serve. If the server has to offer a choice, it serves a document with a "300 Multiple Choices" response code. A "406 Not acceptable" response code could also be served if there are no appropriate candidates. The mod_headers directive states that:
This directive can replace, merge or remove HTTP response headers during 1xx and 2xx series replies. For 3xx, 4xx and 5xx use the ErrorHeader directive.
So I tried the following to take into account the possibility of the request leading to a 300 or 406 response:
[b]ErrorHeader unset Content-Location[/b] Amazingly, it seems to work, and the page is still returned with a 200 OK response header. Don't ask me to explain the logic, though. ;)
HTTP/1.x 200 OK
Content-Location: services.htm
Vary: negotiate
TCN: choice
... and then using an AddHandler to parse files with that extension as PHP works fine.
AddHandler php5-script htm