在 Linux 中, 往往解析一個域名時, 先會找/etc/hosts 檔案, 若/etc/hosts 檔案沒有對應, 才會去找 DNS(/etc/resolv.conf).
那麼這個順序是由什麼決定的呢? 是否可以更改順序呢?
當然有, 在/etc/nsswitch.conf 這個檔案中定義:
#hosts: db files nisplus nis dns
hosts: files dns
這個顯示, 你的 WordPress 主機就會先去找/etc/hosts 檔案, 然後才去找 DNS.
若想先從 DNS(/etc/resolv.conf) 檔案開始解析, 則可以如下修改:
#hosts: db files nisplus nis dns
hosts: dns files
這樣, 你的 WordPress 主機就會先去找 DNS, 再去找 hosts 了.