Skip to content

Instantly share code, notes, and snippets.

@Sgouws
Last active May 27, 2018 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sgouws/5f883d2937c0046bf32ff06d7daf3789 to your computer and use it in GitHub Desktop.
Save Sgouws/5f883d2937c0046bf32ff06d7daf3789 to your computer and use it in GitHub Desktop.
Nginx - Remove file extension from uri

You need to edit the root location block. See before and after below:


Change this:

location / {
  try_files $uri $uri/ =404;
}

To this:

location / {
  try_files $uri.html $uri $uri/ =404;
}

If for example you wanted to do the same for php, use the following:

location / {
  try_files $uri.php $uri.html $uri $uri/ =404;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment