2013-01-24 58 views
2

我有一个UBUNTU/APACHE盒,当我尝试使用HOST-NAME访问Web服务器时,它使我访问DocumentRoot(它是/ var/www)并向我显示所有文件/文件夹)。我有/ var/www/devel和var/www/live几个文件夹,我怎么能更新我的配置,以便当我通过它的主机名[http :// servername]它默认进入DocumentRoot的子文件夹。如何配置Apache的启用站点的配置?

我试图将DocumnetRoot更改为指向/ var/www/live,当我点击主机名时它会将我发送到正确的路径,但我无法再访问/ var/www/dev到[http:// servername/dev])。

这很可能是因为现在/ dev在DocumentRoot之外,我如何调整配置以便在[http:// servername]解析为/ live时仍可以访问[http:// servername/dev] 。

这里是我的配置...

DocumentRoot /var/www 

    <Directory /> 
      Options FollowSymLinks 
      AllowOverride All 
    </Directory> 

    <Directory /var/www> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride All 
      Order allow,deny 
      allow from all 
    </Directory> 

    <Directory "/var/www/dev"> 
      AuthName "NTLM Authentication" 
      NTLMAuth on 
      NTLMAuthHelper "/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp" 
      NTLMBasicAuthoritative on 
      AuthType NTLM 
      require valid-user 
    </Directory> 

    <Directory "/var/www/live"> 
      AuthName "NTLM Authentication" 
      NTLMAuth on 
      NTLMAuthHelper "/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp" 
      NTLMBasicAuthoritative on 
      AuthType NTLM 
      require valid-user 
    </Directory> 

回答

0

,如果你想您所描述的行为,你不改变DocumentRoot的。你需要做的是使用类似mod_rewrite的重定向来“重写”一个url指向你需要的目录。这样你仍然保留了DocumentRoot。它看起来像这样:

RewriteEngine on 
RewriteRule ^/$ /live/ [R] 

查看此链接了解更多的想法。 Redirects