damir
By:
damir

NGINX permanent redirect problem with multiple domains on one droplet

October 11, 2014 4.2k views

Hi,

I have 3 websites (https://www.wknet.se/, https://www.webkreativ.hr/, and http://cdnwknet.com/) on 1 Droplet and I tested all of them with GTMetrix.com and I got one problem with http://cdnwknet.com which is a permanent redirect to https://www.wknet.se/. You can see the problem with it on this report http://gtmetrix.com/reports/cdnwknet.com/Ji4Zja9o.

What I am missing here?

The config file of cdnwknet.com looks like this:

server {
   listen 80;
   listen [::]:80;
   server_name www.cdnwknet.com;

   return 301 http://cdnwknet.com$request_uri;
}

server {
   listen 80;
   server_name cdnwknet.com;

   root /var/www/cdnwknet.com/html;
   index index.php index.html index.htm;

   error_page 403 /error/403.html;
   error_page 404 /error/404.html;

   charset utf-8;

   if ( $request_uri ~ ^(/index\.php)$ ) {
      return 301 http://cdnwknet.com;
   }

   location / {
      try_files $uri $uri/ =404;
      expires max;
      add_header Pragma public;
      add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      access_log off;
      log_not_found off;
      fastcgi_hide_header Set-Cookie;
      tcp_nodelay off;
      break;
   }

   location ~ \.php$ {
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
   }

  location = /error/403.html {
      root /var/www/cdnwknet.com/html;
      allow all;
  }

  location = /error/404.html {
      root /var/www/cdnwknet.com/html;
      allow all;
  }
}

2 comments
  • I'm not seeing the redirect. www.cdnwknet.com redirects to cdnwknet.com, and cdnwknet.com is not redirecting me anywhere.

  • Okay, according to GTmetrix there is a permanent redirect to wknet.se. It must be something wrong on their site then.

Be the first one to answer this question.