【发布时间】:2021-05-30 19:17:55
【问题描述】:
这是 nginx 配置:
location @rewrite {
rewrite ^/threads/ /thread.php?$uri&$args last;
}
该代码运行良好,但我现在想使用另一条路线。
OLD: /threads/123-yyy-yyy-yyy
NEW: /xxx-xxx-xxx/123-yyy-yyy-yyy
我尝试过一些类似的方法:
rewrite ^\/[\w]+\/([\d]+-[\w]+)?$ /thread.php?$1&$args last;
rewrite ^/[\w]+/([\d]+-[\w]+)?$ /thread.php?$1&$args last;
rewrite ^/\w+/(\d+-\w+)?$ /thread.php?$1&$args last;
rewrite ^/\w+/(\d+-\w+)$ /thread.php?$1&$args last;
但是找不到页面,所以我猜我的正则表达式有问题。 可能是 $uri/$1 参数吗?
【问题讨论】:
标签: regex nginx url-rewriting