V
V
venowujux2015-05-03 20:36:54
Nginx
venowujux, 2015-05-03 20:36:54

Nginx how to make a simple redirect?

please tell me how to make a simple redirect in nginx, what needs to be written in the .conf file, so that, for example, when opening (any file) domain.com/123/site.htm redirects to 123.domain.com:8080/site .htm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-05-03
@sim3x

server {
        server_name  domain.com;
        location ~* /(\da-z)+/(.*) {
             return 302 http://$1.domain.com/$2;
        }
# тут нужно обработать остальное
    }

    server {
        listen 8080;
        server_name *.domain.com;
# основная часть конфига
}
not tested, but something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question