gpt4 book ai didi

nginx - 使用 nginx 重定向(从 url 中删除子字符串)

转载 作者:行者123 更新时间:2023-12-04 05:27:56 25 4
gpt4 key购买 nike

我想从旧网址进行重定向:

http://example.org/xxxxxxxxx.html

到新网址(删除“.html”)

http://example.org/xxxxxxxxx

如何使用 nginx 做到这一点?

编辑:

xxxxxxxxx 可以不同,例如:

http://example.org/url-1.html 重定向到 http://example.org/url-1http://example.org/another-url.html 重定向到 http://example.org/another-url

最佳答案

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

关于nginx - 使用 nginx 重定向(从 url 中删除子字符串),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38171713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com