dimanche 28 juin 2015

location direct domain.com to www.domain.com on multi site server

thank you for viewing this. Please advise that my server is running LEMP on Debian Jessie.

I am trying to force "www." to occur. I was able to do this with the following solution found on Stackoverflow.

return       301 http://ift.tt/1mDYAZp;

However, I am running several websites from the server and the issue I am running into is as follows.

When logging into wordpress http://ift.tt/1KiJWke on one website, it routes me to http://ift.tt/1LOLvFH. I believe this issue has to do with a default_server or hostname issue. Do I need to add all hostnames to /etc/hostname ?

Here is my host file

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;

        root /var/www/site0;

        index index.php index.html index.htm;

        server_name site0.com;
        #return 301 http://ift.tt/1KiJWki;
        location / {
                try_files $uri $uri/ =404;
                #try_files $uri $uri/ /index.html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                #fastcgi_index index.php
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

server {
        listen 80;
        listen [::]:80;

        # SSL configuration
        #listen 443 ssl;
        #listen [::]:443 ssl;

        root /var/www/site1;

        index index.php index.html index.htm;

        server_name site1.com;
        #return 301 http://ift.tt/1KiJYZo;
        location / {
                try_files $uri $uri/ =404;
                #try_files $uri $uri/ /index.html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                #fastcgi_index index.php
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

I am thinking part of the issue has to do with: listen 80 default_server; listen [::]:80 default_server;

Please help if you can, it will be very much appreciate.




Aucun commentaire:

Enregistrer un commentaire