原创 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

使用 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
访客IP ,您的网络 访问优先

本站是个人博客,书写大数据、数据科学等领域的原创学习记录,转载请注明出处

本站运行于 腾讯云 腾讯云