2014-01-22 49 views
0

我有一個虛擬主機:www.example.com,其中包含2個子文件夾,即hellohello2hello不包含任何內容,而hello2包含test.html文件。

將特定文件夾重定向到另一個文件夾並使用httpd.conf加載特定頁面

現在我想要做的是,每當我訪問www.example.com/hello我想要的頁面訪問test.htmlhello2子文件夾。

輸出示例:

網址:www.example.com/hello

按下回車後,

網址:www.example.com/hello2/test.html
頁面顯示:這是test.html的



如何我能做到嗎?他的沒有使用.htaccess只是使用httpd.conf配置。我被困了好幾個小時。



這是我做過嘗試,但沒有運氣

<VirtualHost *:80> 
     DocumentRoot /var/www/www.example.com/hello 
     ServerName www.example.com 
     ServerAlias www.example.com 
     Alias /hello /var/www/www.example.com/hello2 
     <Directory /var/www/www.example.com/hello2> 
      #Options FollowSymLinks 
      Options Indexes FollowSymLinks Includes ExecCGI 
      AllowOverride All 
      Order deny,allow 
      Allow from all 
      RewriteEngine on 
      RewriteRule ^/index\.html$ test.html [R] 
     </Directory> 
</VirtualHost> 

預先感謝您。

回答

0

我想通了,把這個在httpd.conf

<VirtualHost *:80> 
     DocumentRoot /var/www/example.com 
     ServerName www.example.com 
     ServerAlias www.example.com 
     Alias /hello /var/www/www.example.com/hello2 
     RewriteEngine On 
     Redirect 301 /hello http://www.example.com/hello2/test.html 
</VirtualHost> 
相關問題