NGINX Redirect special characters @


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

If the URL contains @ then redirect it to

but also include the original @customname

Most of my location blocks currently look like this

    /location {
    return 301 $scheme://$request_uri;

So to summarize if you visit 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!