使用 nginx 重定向(从 url 中删除子字符串) [英] Redirect with nginx (remove substring from url)
本文介绍了使用 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;
}
这篇关于使用 nginx 重定向(从 url 中删除子字符串)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文