2013-01-24 64 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