如何在Nginx中重写单个单词

时间:2014-03-18 14:51:54

标签: nginx rewrite

我想将包含特定单词的所有网址重写为另一个单词,例如:

www.example.com/one/myword/two

应重写为

www.example.com/one/editedword/two

但也

www.example.com/one/myword

应重写为

www.example.com/one/editedword

等等...

谢谢。

1 个答案:

答案 0 :(得分:0)

我找到了一个适用于我的解决方案:

rewrite ^/one/myword(.*)$ /one/editedword$1 permanent;