Skip to content

Instantly share code, notes, and snippets.

@3m1n3nc3
Created January 27, 2023 02:00
Show Gist options
  • Save 3m1n3nc3/c243ed233ed325f35cee23261a69e3d4 to your computer and use it in GitHub Desktop.
Save 3m1n3nc3/c243ed233ed325f35cee23261a69e3d4 to your computer and use it in GitHub Desktop.
Hidding .php and .html file extension from URL on Nginx
location / {
try_files $uri $uri.html $uri/ @extensionless-php;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
}
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