2011-03-27 74 views
0

所以我在同一个IP上有两个不同的站点。基本上我只想将流量从一个域指向某个文件夹,并从另一个域指向另一个文件夹。我读了这个页面... http://httpd.apache.org/docs/2.0/vhosts/examples.html,并设置我的网站启用配置文件看起来像这样,但我的第二个域名只是路由流量到我的原始网站。Apache 2上虚拟主机的问题 - 没有指向适当的虚拟主机

所以...... 域1:cdphoto.uni.cc 域2:wtfdoidoatubc.uni.cc

我的配置文件看起来像this

感谢您的任何建议!

回答

0

在这种情况下,使用控制面板并添加重定向是一个不错的主意,除非您打算将某个网站的主要部分用于某些事情。但是,如果不是来自主机控制面板的重定向规则将是最好和最简单的选择。

+0

我不确定您的控制面板是什么意思?我假设你的意思是一个主机CP,但是这个站点只是托管在我有的一台备用计算机上。 – Chris 2011-03-29 00:55:15

+0

在这种情况下,您需要为每个站点设置2个单独的文件夹。然后更新您的.htaccess以反映相同。 – 2011-03-30 02:01:01

0

也许尝试使用DocumentRoots/var/www/site1和/ var/www/site2?现在第二个站点位于第一个子文件夹中。如果你要求http://www.cdphoto.uni.cc/wtf会发生什么?

+0

我试过这样做,出于某种原因它不起作用。 Apache只选择我的000默认文件中的任何一个VirtualHost站点,并将所有流量重定向到那里。 – Chris 2011-03-29 00:55:59

0

我会试一试,并确保您记下我对第一个文档根所做的更改。

<VirtualHost *:80> 
    ServerAdmin [email protected] 

    DocumentRoot /var/www/cdp 
    ServerName www.cdphoto.uni.cc 
    <Directory /> 
     Options FollowSymLinks 
     AllowOverride None 
    </Directory> 
    <Directory /var/www/cpd> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride None 
     Order allow,deny 
     allow from all 
    </Directory> 

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
    <Directory "/usr/lib/cgi-bin"> 
     AllowOverride None 
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
     Order allow,deny 
     Allow from all 
    </Directory> 

    ErrorLog /var/log/apache2/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 

    CustomLog /var/log/apache2/access.log combined 

    Alias /doc/ "/usr/share/doc/" 
    <Directory "/usr/share/doc/"> 
     Options Indexes MultiViews FollowSymLinks 
     AllowOverride None 
     Order deny,allow 
     Deny from all 
     Allow from 127.0.0.0/255.0.0.0 ::1/128 
    </Directory> 

    <Location /trac> 
     SetHandler mod_python 
     PythonInterpreter main_interpreter 
     PythonHandler trac.web.modpython_frontend 
     PythonOption TracEnvParentDir /var/www/trac 
     PythonOption TracUriRoot /trac 
    </Location> 

</VirtualHost> 
    <VirtualHost *:80> 
     DocumentRoot /var/www/wtf 
     ServerName www.wtfshouldidoatubc.uni.cc 
    </VirtualHost>