Clean up the appearance of URLs slightly by removing file extensions from the URL path. Should not be misinterpreted as a way to ‘cloak the technology in use’, but rather just to tidy up URLs a bit.
To allow extension-less filenames in URLs, add the following location block:
server {
# ...
location / {
try_files $uri.php $uri $uri/ =404;
}
# ...
}
This would cause requests to /articles/popular to be:
- rewritten as /articles/popular.php if that file physically exists
- if not, and there is already an extension-less file, then it will be served
- if neither of those apply but there is a directory named /articles/popular/ then that will be served
- and finally, if none of those exist the server will return a 404 Not Found.
Replace or add variations of $uri.php with the file extension appropriate for your given language.