I
I
i_want_to_know_everything2016-11-24 11:17:35
Nginx
i_want_to_know_everything, 2016-11-24 11:17:35

Nginx redirect not working?

server {
    server_name subdomain.domain.com;
    listen 80;
    return 301 http://google.com;
}

server {
  server_name domain.com www.domain.com;
  listen 80;
  return 301 https://$server_name$request_uri;
}

why with such a config subdomain.domain.com; still redirects to https://domain.com

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
akzhan, 2016-11-24
@i_want_to_know_everything

I did not look at return, rewrite works in the working config:

server {
    listen [% $site.port %];

    server_name www.[% $site.host %];

    rewrite ^/?(.*) $scheme://[% $site.host %]/$1 permanent;
}

However, it works well
server {
    listen [% $site.port %];
    server_name www.[% $site.host %];

    return 301 $scheme://[% $site.host %]$request_uri;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question