0

i need to redirect few URLs. 301 permanent

http://example.com/downloads/example.exe to http://example.com/emaple-page/

i need to do this for 3 URLS , i'm going to do this on .conf file

 server {
    listen 80;
    server_name http://example.com/downloads/example.exe;

    rewrite ^/(.*) http://example.com/emaple-page/$1 permanent;
}
    server {
    listen 80;
    server_name http://example.com/downloads/example2.exe;

    rewrite ^/(.*) http://example.com/emaple-page/$1 permanent;
}
    server {
    listen 80;
    server_name http://example.com/downloads/example3.exe;

    rewrite ^/(.*) http://example.com/emaple-page/$1 permanent;
}

i want to know is this correct ? what is the best way to do it ?

Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81
djchamike
  • 3
  • 1

1 Answers1

0

You can have only 1 server section for each domain. You can put the original URL directly in the rewrite clause.

server {
  listen 80;
  server_name example.com;
  index index.html index.php
  rewrite ^/downloads/example\.exe  http://example.com/emaple-page/  permanent;
  rewrite ^/downloads/example2\.exe http://example.com/emaple-page2/ permanent;
  rewrite ^/downloads/example3\.exe http://example.com/emaple-page3/ permanent;
}
Marki555
  • 6,434
  • 3
  • 37
  • 59