Nginx rewrite - remove substring at the end of URL

I have a faulty plugin that is generating URLs with /mobile at the end. I am trying to fix the plugin but in the meantime I would like to write a Nginx rewrite rule to redirect as shown below:

http://www.domain.com/article-slug/mobile

to

http://www.domain.com/article-slug/

Can some help me with coming up with the rewrite rule? I researched but could not find something that works in my case. Thanks for your time.

1
задан 5 May 2016 в 01:35
1 ответ

Ваша перезапись не будет выполнять перенаправление, но будет делать что-то более похожее на внутреннюю пересылку. Предполагая, что вы хотите отправить 301, вы должны сделать:

rewrite ^(.*/)mobile$ $1 permanent;
0
ответ дан 4 December 2019 в 06:19

Теги

Похожие вопросы