簡體   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