nginxurl-rewritinghttp-redirectngx-http-rewrite-module

Redirect with nginx (remove substring from url)


I want do a redirect from old url:

http://example.org/xxxxxxxxx.html

To new urls (remove ".html")

http://example.org/xxxxxxxxx

How I can do this with nginx?

EDIT:

xxxxxxxxx can be differ, example:

http://example.org/url-1.html redirect to http://example.org/url-1 http://example.org/another-url.html redirect to http://example.org/another-url


Solution

  • location ~ ^(.*)\.html$ {
        return 301 $1;
    }