2017-04-18 114 views
0

我在服务提供商处注册了多个域,并使用nginx在linode上托管。如何在多域环境中将非www重定向到nginx中的WWW

域名的例子是www.example.com(不example.com)

所有域工作的罚款以www但没有它的页面没有加载。

In curl -I http://example.com 

它导致

curl: (6) Could not resolve host http://example.com 

我有3个分别为每个

blank IP 
mail  IP 
www  IP 

A/AAAA记录在我的/etc/nginx/sites-available

server { 
     listen 80; 
     listen [::]:80; 
     server_name example.com www.example.com; 
     access_log /var/log/nginx/example.com.log; 
     error_log /var/log/nginx/example.com-error error; 

     root /var/www/examplecom/public; 
     index index.html index.php; 

     location ~ \.php?$ { 
      try_files $uri =404; 
      include fastcgi_params; 
      fastcgi_pass unix:/var/run/php-main.socket; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_intercept_errors on; 
      fastcgi_split_path_info ^(.+\.php)(.*)$; 
      #Prevent version info leakage 
      fastcgi_hide_header X-Powered-By; 
     } 
} 

server { 
    listen 80; 
    server_name example.com; 
    return 301 $scheme://www.example.com$request_uri; 
} 

我也写了尝试第二台服务器b锁定在最高但结果相同。

请立即指导/帮助。

+0

'无法解析host' - 意味着你应该配置你的DNS正常 –

+0

DNS可以需要一些时间来传播。假设你的A记录表示'空白'实际上是空白的(根级'example.com'而不是'blank.example.com'),你的DNS配置看起来是正确的。 –

回答

0

谢谢各位回复。

通过当我的Linode设置改变了我的域名从www.example.com的问题得到解决的方式example.com

相关问题