Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX rewrite rule doesn't match with REGEX (.+)

We are trying to rewrite a link like this:

https://example.com/some/thing/?tx_career_view%5BjobUid%5D=12&tx_career_view%5Baction%5D=show&tx_career_view%5Bcontroller%5D=Job&cHash=2d8595af0dfc0bf1e8b75d88849f

Our rule looks like this:

rewrite ^/some/thing/(.+)   /some/where/else/ permanent;

In https://regex101.com/ it says our REGEX matches, but NGINX doesn't rewrite.

like image 226
Sero Avatar asked Dec 03 '25 16:12

Sero


1 Answers

As @RichardSmith pointed out, the URL arguments are not matched against (as in, for your URL, it is /some/thing/). Since you want to rewrite for any arguments, simply use:

rewrite ^/some/thing/  /some/where/else/ permanent;
like image 146
Danila Vershinin Avatar answered Dec 06 '25 06:12

Danila Vershinin