NGINX location rewrite URL with or without trailing slash
<p>Currently I have this location block:</p>

<pre><code>location = /events {
    rewrite ^ https://totallydifferenturl.com;
}
</code></pre>

<p>This successfully redirects from <code>mywebsite/events</code>, but I want this block to also handle <code>mywebsite/events/</code>.</p>

<p>Trying <code>location = /events/?</code> didn't work out.</p>