I
I
IvanOne2016-01-27 08:13:29
Django
IvanOne, 2016-01-27 08:13:29

Why does the www redirect not work?

There is such a nginx server configuration


server {
server_name www.cool-fin.ru;
rewrite ^(.*) http://cool-fin.ru$1 permanent;
}
server {
listen 80;
server_name cool-fin.ru;
...

But the redirect does not work, if you try to go to an address without www, it says Aborted and nothing happens. There is nothing in the server logs, it seems that the request simply does not reach. OC Ubuntu 14.04.2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Muidinov, 2016-01-27
@IvanOne

server {
listen 80;
server_name www.cool-fin.ru;
return 302 http://cool-fin.ru$request_uri;
}
nginx -t
nginx -s reload

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question