简体   繁体   English

apache VirtualHost重定向到其他VirtualHost

[英]apache VirtualHost redirecting to different VirtualHost

I am very new to Apache2 and I am attempting to serve two websites on a server. 我是Apache2新手,我正在尝试在服务器上服务两个网站。

I have followed the documentation here: https://httpd.apache.org/docs/current/vhosts/examples.html 我在这里遵循了文档: https : //httpd.apache.org/docs/current/vhosts/examples.html

and have attempted: 并尝试过:

<VirtualHost *:80>
    DocumentRoot "var/www/websiteexample1.com"
    ServerName www.websiteexample1.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "var/www/websiteexample2.com"
    ServerName www.websiteexample2.com
</VirtualHost>

However if i attempt to go to www.websiteexample2.com I am instead directed to the content of www.websiteexample1.com 但是,如果我试图去www.websiteexample2.com我,而不是指向的内容www.websiteexample1.com

What am i missing? 我想念什么?

Your issue may be that you have not setup an associated Directory in the main conf file? 您的问题可能是您尚未在主conf文件中设置关联的目录? Something along the lines of :- 遵循以下原则:

#======================================================================
# Note this one is for the secondary root (for www.websiteexample2.com
# This should be changed to whatever you set DocumentRoot to.

<Directory "Your 2nd Website's Directory here">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
        Allow from all
</Directory>

You also need to tell Apache to use/look at the virtual hosts file. 您还需要告诉Apache使用/查看虚拟主机文件。 So if you haven't got the following, ensuring that it is not commented out and that it points to the correct location :- 因此,如果您没有以下内容,请确保未将其注释掉并指向正确的位置:-

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

This based upon a 2.2.6 version of Apache 这基于Apache 2.2.6版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM