使用 nginx 重定向(从 url 中删除子字符串)
问题描述:
我想从旧网址重定向:
http://example.org/xxxxxxxxx.html
到新网址(删除.html")
To new urls (remove ".html")
http://example.org/xxxxxxxxx
我如何用 nginx 做到这一点?
How I can do this with nginx?
编辑:
xxxxxxxxx
可以不同,例如:
http://example.org/url-1.html
重定向到 http://example.org/url-1
http://example.org/another-url.html
重定向 到 http://example.org/another-url
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
答
location ~ ^(.*)\.html$ {
return 301 $1;
}