Nginx rewrite: remove .html from URL with arguments

Posted by Darko on Server Fault See other posts from Server Fault or by Darko
Published on 2012-10-17T10:46:32Z Indexed on 2012/10/17 11:03 UTC
Read the original article Hit count: 549

Filed under:
|

How can i remove the .html from an url with argument?

eg: http://www.domain.com/somepage.html?argument=whole&bunch=a-lot

to:

http://www.domain.com/somepage?argument=whole&bunch=a-lot

I have tried

    location / {
    index index.html index.php; 
            rewrite ^\.html(.*)$ $1 last;
            try_files $uri $uri/ @handler; 
            expires 30d; ## Assume all files are cachable
     }

and a bunch of other suggestions, but can't seem to make it work....

Tnx

© Server Fault or respective owner

Related posts about nginx

Related posts about rewrite