i'm try to setup multiple wordpress sites on my Amazon EC2 instance. Here's how my httpd.conf file looks like:
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com
DocumentRoot /var/www/html/domain1
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.co
ServerAlias domain2.co
DocumentRoot /var/www/html/domain2
</VirtualHost>
So, when i entered domain1.com or www.domain1.com in the browser, it redirects correctly to the content i wanted and so does www.domain2.co . However, when i entered domain2.co, it doesn't directs to the ServerName www.domain2.co but to the first VirtualHost settings www.domain1.com.
Anything i'm missing out here?
答案 0 :(得分:0)
Try this. Apache will default to the 1st virtual host if it doesn't find a virtualhost match which means your second VirtualHost is being ignored. We use www. as an alias and the domain as the server name. See if this helps.
<VirtualHost *:80>
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html/domain1
</VirtualHost>
<VirtualHost *:80>
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/html/domain2
</VirtualHost>
答案 1 :(得分:0)
想出来的人,当domain2.co指向domain1.com时,浏览器会缓存以前的数据。因此,即使我为domain2.co正确设置了虚拟主机,浏览器仍会从domain1.com加载以前的缓存数据。
解决方案是清除浏览器数据。
发现影响这种情况的另一个因素可能是因为您的ISP。
在此处阅读更多内容:https://sg.godaddy.com/help/what-factors-affect-dns-propagation-time-1746