virtualhost multiple sites, apache linux server

2019-08-24 01:58发布

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条回答
孤傲高冷的网名
2楼-- · 2019-08-24 02:17

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>
查看更多
登录 后发表回答