Can someone help with a URL rewrite rule please


#1

I would like to have users come to myurl.com/code (example: myurl.com/3928). They should see a wordpress page myurl.com/contact. I would like the script on myurl.com/contact to be able to use the code (3928). No matter what the code provided in the URL is, the user will see the same page, /contact.

I am guessing I need a rewrite rule, and I am having a lot of trouble understanding how to do it. I’ve placed the code in the file /var/www/myurl.com/conf/nginx/rewrites.conf. I first tried:

location ~ / {
    rewrite ^/code/(.*)$ /contact?code=$1;
}

and then

location ~ / {
    try_files $uri $uri/ /contact?$args;
}

I’m a little confused – if anyone can point me in the right direction I’d be grateful.

Thanks


#2