Month: April 2015

nginx redirection pitfalls

Hola,

I’ve recently faced a wierd issue with nginx.(my noobness :))

I was redirecting requests from a.domain.com to b.domain.com using below-

server
{
    listen 80;
    server_name a.domain.com;
    return 301 http://b.domain.com$request_uri;
}

I’ve given same a.domain.com in another directive too-

server
{
    listen 80;
    server_name domain.com a.domain.com b.domain.com;
    charset utf-8;
    index index.php index.html index.htm;
    root /home/xyz/www/;
    location /media {
        alias /home/xyz/media/;
    }
}

This has created hell lot of mess. Every url was getting redirected to b.domain.com

Reason: I have not found good explaination yet but basic point is, that created an error and nginx redirected all requests to default

Advertisements