原创 Nginx 301 单页面重定向
参照 NGINX 官方重定向的文章 Module ngx_http_rewrite_moduleopen in new window , 修改 NGINX 配置。
server {
...
## qcloud
location /go/discount/2c2g40yuan {
rewrite ^/.* https://cloud.tencent.com/act/cps/redirect?redirect=1577&cps_key=06d5d20d253db4b3d08d1d1dc7a0dfe9&from=console permanent;
}
...
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
使用 curl 命令验证,看到 301 重定向的效果。
$ curl -I https://dhcp.cn/go/discount/2c2g40yuan
HTTP/2 301
server: istio-envoy
date: Sun, 27 Feb 2022 00:41:40 GMT
content-type: text/html
content-length: 169
location: https://cloud.tencent.com/act/cps/redirect?redirect=1577&cps_key=06d5d20d253db4b3d08d1d1dc7a0dfe9&from=console
x-envoy-upstream-service-time: 20
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8