NGINX Redirect special characters @

Hello,

Does anyone know how to write the correct redirect location block for urls that contain @? For example:

https://example.com/@customname

If the URL contains @ then redirect it to

https://example.com/mycustomphpfile.php

but also include the original @customname

Most of my location blocks currently look like this

    /location {
    server_name www.mysite.com;
    return 301 $scheme://mysite.com$request_uri;
}

So to summarize if you visit example.com/@customname then it redirects to mycustomphpfile.php which I can then explode the URL, get the correct data, and then deliver the correct info to the user.
I don’t want to create an insane amount of directories for each user.

Just not sure how to write the correct formatting here. Any help is much appreciated!