Nginx remove html from url

If you have a static website build using plain html files, your url will look like https://yourdomain/page.html. This .html extension is useful for the files when it is on your local computer, it help computer to associate the file with specific application, say your HTML editor. But on a web server this .html extension serve no purpose. If you are using Nginx web server, you can remove .html extension from your web page urls with following code.

Remove .php extension

To remove .php extension, you can use

Reataining Arguments

To retain arguments, use

This will redirect /mypage.html?name= to /mypage?name=

Serve PHP file with .html extension

See Nginx

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *