Manually Configuring the Redirect on VPS

Hi,

I am stuck with redirect rules for NGINX.

Got a suggestion by EDD:

Option 1:

rewrite ^/wp-content/uploads/edd/(.*)\.zip$ / permanent;

Option 2:

rewrite ^/wp-content/uploads/edd/(.*)/(.*)\.zip$ / permanent;

But I have no clue how to do this! :thinking:

Help, please.

Regards
Pratyaksh Somani

You have written above code for Apache.

For NGINX, it should be added in the config file this way under server block which can be found under /etc/nginx/sites-available/ directory

It will look like this

Note: Depending upon how server stack was configured it may vary.

server {
listen 80;
root /var/www/html;
index index.php index.html index.htm;
server_name example.org www.example.com.org;
client_max_body_size 0;

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
...

:point_right: There you need add code for Easy Digital Download to prevent unauthorized access to zip files.

  location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ { 
    rewrite / permanent; 
  } 

Alternative way to achieve the same -

  • Using Redirection plugin with RegEx mode. This may be easier.
1 Like