繁体   English   中英

nginx重写单个URL wordpress

[英]nginx rewrite single URL wordpress

我需要在nginx中重写一个URL,但是我的正则表达式fu被弄坏了。

我想做的就是重写:

https://www.drake.org.uk/2012/07/os-x-mountain-lion-clean-install-gotcha-corestorage-encrypted-disk-issue

成为

https://www.drake.org.uk/os-x-mountain-lion-clean-install-gotcha-core-storage-encrypted-disk-issue/

(您会看到,没有2012/07的URL是不同的-我把它弄糟了,现在更改它而不做更多重写就为时已晚!)

我试过了:

rewrite ^/2012/07/os-x-mountain-lion-clean-install-gotcha-corestorage-encrypted-disk-issue 
https://www.drake.org.uk/os-x-mountain-lion-clean-install-gotcha-core-storage-encrypted-disk-issue permanent;

(全部一行以上)

和各种组合(包括转义斜线),但似乎无济于事。

有没有一种快速的“ n”简单方法来做到这一点?

任何帮助,不胜感激。

我认为此正则表达式可以帮助您:

/(\/?\d+\/)+/i

带替换( \\

[正则表达式演示]

暂无
暂无

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

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