B
B
Bastax132017-02-22 04:54:15
Nginx
Bastax13, 2017-02-22 04:54:15

How to redirect from subdomain to NGINX folder?

It is necessary that when accessing test.site.com, it is redirected to site.com/test and so on for all subdomains.
That is abc.site.com -> site.com/abc
xyz.site.com -> site.com/xyz
How to implement on nginx ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nurlan, 2017-02-22
@Bastax13

server{
    server_name *.sss.local sss.local;
    if ($host ~* ^([a-z\.]+)\.sss.local$) {
        return 301 http://sss.local/$1$request_uri;
    }
}

I
Ilya, 2017-02-22
@nuBacuk

server {
  listen 80;
  server_name test.site.com;
  return 301 http://site.com/test$request_uri;
    rewrite ^(.*) http://site.com/test$uri permanent;

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question