Answer the question
In order to leave comments, you need to log in
How to set up a redirect to a third level domain (nginx)?
How to set up a redirect
- there is site.ru/index.php
on port 80,
- there is a file It is site.ru/old.php
necessary to transfer from users old.site.ru
to a file site.ru/old.php
using 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:
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
server {
listen 80;
server_name old.site.ru;
return 301 http://site.ru/old.php;
}
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 questionAsk a Question
731 491 924 answers to any question