2017-04-18 112 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

相關問題