Question
Two domains on the same Nginx server
Hi, I have one site already set up on Nginx and tried to add a second but is not working.
Every time I try to access the second field I am directed to the first domain. What might be happening?
site1 = inforlogia.com
site2 = tudodesconto.com
config for site1:
server {
listen 80 default_server;
error_log /var/www/error.log;
access_log off;
root /var/www/inforlogia.com;
server_name inforlogia.com;
index index.php;
include /etc/nginx/wordpress.conf;
}
config for site2:
server {
listen 80;
listen [::]:80;
error_log /var/www/error.tudodesconto.log;
access_log off;
root /var/www/tudodesconto.com;
server_name tudodesconto.com;
index index.php;
include /etc/nginx/wordpress.conf;
}
wordpress.conf
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.html;
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}
location ~ \.conf$ {
deny all;
}
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×