virtualhost multiple sites, apache linux server

不羁的心 提交于 2019-12-11 14:07:27

问题


Sorry if this sounds stupid, its how I feel since I've done this in the past and can't figure out whats wrong.

Anyways, I had two sites setup on my fedora linux box, now I'm trying to add a third site. However when I go to www.site3.com it gets redirected to the first site.

My VirtualHost code is very basic, please let me know what else I should be adding and any issues you can see which result to the issue I mentioned.

httpd.conf:

<VirtualHost *:80>
   DocumentRoot /var/www/html/web/site1/
   ServerName site.com
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot /var/www/html/web/site2/
   ServerName site2.com
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot /var/www/html/web/site3/
   ServerName site3.com
</VirtualHost>

Is there anything else I need to change other than this? The other first two sites still work fine, I've restarted the httpd service, but no avail

Thanks in advance


回答1:


www.site3.com and site3.com are not the same hostname. See the ServerAlias directive.

<VirtualHost *:80>
   DocumentRoot /var/www/html/web/site3/
   ServerName site3.com
   ServerAlias www.site3.com
</VirtualHost>


来源:https://stackoverflow.com/questions/11421468/virtualhost-multiple-sites-apache-linux-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!