Currently I have this location block:
location = /events {
rewrite ^ https://totallydifferenturl.com;
}
This successfully redirects from mywebsite/events, but I want this block to also handle mywebsite/events/.
Trying location = /events/? didn't work out.
You need the ~ operator to enable regex matching, and since you only need to match website/events or website/events/ as full strings, you will need anchors ^ and $ around the pattern:
location ~ ^/events/?$
^ ^ ^
The ^/events/?$ pattern matches:
^ - start of input/events - a literal substring /events
/? - one or zero / symbols$ - end of input.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With