Skip to content

Instantly share code, notes, and snippets.

@macariojames
Created August 14, 2018 20:17
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 macariojames/cc3d99f7b95583755e027bc03cc7969e to your computer and use it in GitHub Desktop.
Save macariojames/cc3d99f7b95583755e027bc03cc7969e to your computer and use it in GitHub Desktop.
Nginx hide .php file extension but make sure the home page -- index.php -- page works
# This is in the server {} section of the /sites-available domain
location / {
#notice the $uri space $uri/ space before the @ function for the re-writes
try_files $uri $uri/ @extensionless-php;
index index.html index.htm index.php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment