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 :)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

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:

by Justin Ellingwood
Nginx is one of the most popular web servers in the world. In this guide, we will discuss how Nginx selects the server and location block that will handle a given client's request. We will go over the algorithm in place, as well as the directives and options you can use to modify the selection process.
  • 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.

Submit an Answer