Clean URL for html & php with nginx lemp
I used the lemp install and cannot get a good answer to remove the extension .html or php of the url. Any help would be great :)
Log In to Comment
I used the lemp install and cannot get a good answer to remove the extension .html or php of the url. Any help would be great :)
Adding a location block to your Nginx configuration with a try_files
directive like the one below will allow URLs without php or html extensions to work correctly:
location / {
try_files $uri $uri/ $uri.html $uri.php;
}
For more information on how the try_files
directive works, check out this tutorial:
In my experience, this doesn't work. Even with the proper php-fpm block setup, the files just download as opposed to running which is obviously not good.