Non-www shows default Wordpress Theme


#1

Dear EasyEngine,

I am having the following problem. When a user navigates to our website through example.com (non-www) they sometimes get a wordpress installation with the default theme and post (the “Your first post!”-post). When users navigate to our website through www.example.com they always receive the correct website.

Also some users are reporting to receive the default nginx welcome page, it seems to only occur with the non-www adresss. Anybody seen/experienced this before and maybe knows what is going on?

Website:

Please let me know if you need anymore information (nginx config / site specific config file?).

Thank you,


#2

Hi @MeRuud Refer to this link https://rtcamp.com/tutorials/nginx/www-non-www-redirection/ . If this doesn’t fixe your problem , please let me know .


#3

@MeRuud

can you give me nginx configuration for your site

ee site show www.crossroadshomes.com


#4

Thanks for the help guys.

@Rajdeep_Sharma, I tried this but the page goes completely blank.

server {
    server_name "~^(?!www\.).*" ;
    return 301 $scheme://www.$host$request_uri;
}

@harshadyeola

Display NGINX configuration for crossroadshomes.com
server {
  server_name crossroadshomes.com  www.crossroadshomes.com;
  access_log /var/log/nginx/crossroadshomes.com.access.log;
  error_log /var/log/nginx/crossroadshomes.com.error.log;
  root /var/www/crossroadshomes.com/htdocs;
  index index.php index.html index.htm;
  include common/w3tc-hhvm.conf;
  include common/wpcommon.conf;
  include common/locations.conf;
  include /var/www/crossroadshomes.com/conf/nginx/*.conf;
}

#5

@MeRuud

I need some more details to debug issue

grep -Hrn crossroadshomes.com /etc/nginx/sites-available

I assume that you need your website to be run on www.crossroadshomes.com domain

for now i will suggest to modify your config as below

server {
    server_name crossroadshomes.com;
    return 301 $scheme://www.crossroadshomes.com$request_uri;
}

server {
  server_name www.crossroadshomes.com;
  access_log /var/log/nginx/crossroadshomes.com.access.log;
  error_log /var/log/nginx/crossroadshomes.com.error.log;
  root /var/www/crossroadshomes.com/htdocs;
  index index.php index.html index.htm;
  include common/w3tc-hhvm.conf;
  include common/wpcommon.conf;
  include common/locations.conf;
  include /var/www/crossroadshomes.com/conf/nginx/*.conf;
}

#6

My apologizes for the late reply and thanks for all the help.

grep -Hrn crossroadshomes.com  /etc/nginx/sites-available

/etc/nginx/sites-available/crossroadshomes.com:2:    server_name crossroadshomes.com  www.crossroadshomes.com;

/etc/nginx/sites-available/crossroadshomes.com:4:    access_log /var/log/nginx/crossroadshomes.com.access.log;

/etc/nginx/sites-available/crossroadshomes.com:5:    error_log /var/log/nginx/crossroadshomes.com.error.log;

/etc/nginx/sites-available/crossroadshomes.com:7:    root /var/www/crossroadshomes.com/htdocs;

/etc/nginx/sites-available/crossroadshomes.com:13:    include /var/www/crossroadshomes.com/conf/nginx/*.conf;

@harshadyeola

I assume that you need your website to be run on www.crossroadshomes.com domain

Yes, I would like the default to be www.crossroadshomes.com … all other redirects back to the www.


#7