V
V
Vyacheslav Kordienko2016-10-24 15:26:39
linux
Vyacheslav Kordienko, 2016-10-24 15:26:39

How to set up a redirect to a third level domain (nginx)?

How to set up a redirect
- there is site.ru/index.phpon port 80,
- there is a file It is site.ru/old.php
necessary to transfer from users old.site.ruto a file site.ru/old.phpusing nginx
Registered in hosts on the server 127.0.0.1 localhost site.ru old.site.ru
And I figured Nginx like this, but it does not work:

spoiler
server {
    listen 80;
    server_name old.site.ru;
    location / {
        root /путь/ксайту/;
        index old.php;
    }
    location ~* \.(gif|jpg|png)$ {
        expires 30d;
    }

location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
    }
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ {
                   access_log off;
                   expires max;
                   error_page 404 = /404.html;
    }

}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Burov, 2016-10-24
@BuriK666

server {
    listen 80;
    server_name old.site.ru;
    return 301 http://site.ru/old.php;
}

R
romy4, 2016-10-24
@romy4

>
redirect where in your redirect settings. I do not see

V
Vyacheslav Kordienko, 2016-10-24
@AmonTobin

As I understand it, to start with old.site.ru, the address must be added to the DNS records of the hoster?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question