location 规则如下:
server_name baidu.cn; location ~ ^/f/([0-9]+) { set $port_num $1; rewrite ^/f/(.*) http://baidu.cn/?short=$port_num permanent; }
访问 baidu.cn/f/88 时,$port_num 是 88. 而访问 baidu.cn/f/5000 时,$port_num 是 5 而不是 5000. 有知道是什么原因的吗、
![]() | 1 eason1874 2022-05-24 14:39:13 +08:00 这配置,我测试没问题,应该不是这里导致的异常 另外,只是重写的话,一句 rewrite 就够了,不用 location 匹配 rewrite ^/f/([0-9]+)$ http://baidu.cn/?short=$1 permanent; |