繁体   English   中英

重写Nginx规则以删除URL上的ID

[英]Rewrite nginx rule for delete ID on url

我需要为网址帖子(wordpress)上的删除ID编写规则

https://myqite.com/12-title-of-post-one
https://myqite.com/45-title-of-post-two
https://myqite.com/56-title-of-post-nn

https://myqite.com/title-of-post-one
https://myqite.com/title-of-post-two
https://myqite.com/title-of-post-nn

尝试几种选择,但失败。

rewrite ^([0-9]+)-(.+)$ $2 permanent;

其他

rewrite ^([0-9]+)-(.+)$ $2 last;

经过几次测试我得到了解决方案

location ~ /([0-9]+)-(.+) {
   return 301 https://$server_name/$2;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM