Nginx rewrite: remove .html from URL with arguments

Solution 1:

Modify your configuration like this:

# rewrite html extensions
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;

location / {
    index index.html index.php;
    # this way nginx first tries to serve the file as an .html although it doesn't have the extension
    try_files $uri.html $uri $uri/ @handler;
}

Ofcourse you can add any cache settings etc. but this should be enough to remove the .html part.