Where do I put this redirect script in Nginx

This is the redirect script provided by Yoast.

location /redirect/ { rewrite ^/redirect/(.*)$ /redirect/index.php?id=$1 last; }

But the question is where do I put it in the Nginx.

I tried this: ee site edit example.com

But couldn’t find the “location /” as stated by yoast.

please see the script on Github: https://gist.github.com/jdevalk/5623050


You need to add this in your nginx vhost configuration, so probably in /etc/nginx/sites-available/yoursitename

No I don’t think so.

It seems that your process leads me to the same ee site edit domain.com.

I need to put

location /redirect/ { rewrite ^/redirect/(.*)$ /redirect/index.php?id=$1 last; }

I think it will be placed inside common/locations.conf

Any help how to reach this dir

Sorry, I was not sure if your server was setup with EasyEngine or with a custom nginx configuration. All files in /etc/nginx/common folder are used by EE to set configuration for all your websites depending on the argument used with ee site create If you want to add this configuration only for a single website, then just create a configuration file like redirect.conf in /var/www/yourwebsite.com/conf/nginx and copy your location configuration in this file.

Then just reload nginx withnginx -t && service nginx reload.