Reinis Rozitis
January 31, 2020 07:38AM
>
> if ($args ~ "^p=(\d+)") {
> set $page $1;
> set $args "";
> rewrite ^.*$ /p/$page last;
> break;
> }
>
> I knew there'd be a simpler way and I due to the time of night I was
> struggling.

To add to this (and the map variant by Francis) if the parameter is always 'p' you can just use $arg_p rather than regex on $args or whole $request_uri:

if ($arg_p) {
return 301 http://yoursite/p/$arg_p;
}

or

map $arg_p $hugo_url {
1234 /this_nice_title;
}
....



rr

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewriting $arg into request.

Steve Wilson January 30, 2020 08:14PM

Re: rewriting $arg into request.

Francis Daly January 31, 2020 06:30AM

Re: rewriting $arg into request.

Steve Wilson January 31, 2020 07:12AM

RE: rewriting $arg into request.

Reinis Rozitis January 31, 2020 07:38AM

Re: rewriting $arg into request.

Steve Wilson January 31, 2020 05:00PM

Re: rewriting $arg into request.

Francis Daly January 31, 2020 08:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 253
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready