回文章列表
作者appleboy46.bbs@ptt.cc (我是道明柏毅) 看板: linux
標題[問題] apache mod_rewrite 對 virtual host 作法
時間批踢踢實業 (2008/03/04 Tue 14:03:19)
我昨天在酷學園發表過這篇問題

http://phorum.study-area.org/index.php/topic,50648.0.html

問題如下

剛剛看到一篇酷學園精華區文章

http://phorum.study-area.org/index.php/topic,17120.0.html

這篇裡面提到

引用
<quote>
以下有部份取自原來我貼在 VBird 的文章
Apache 的 VH 其實設法相當多種,
相信大多數都是這種設法
<VirtualHost 1.2.3.80:80>
ServerAdmin admin@xxx.com.tw
DocumentRoot /home/httpd/html/enum
ServerName VH1.xxx.com.tw
ErrorLog logs/VH1-error.log
CustomLog logs/VH2-access_log common
</VirtualHost>
因為書本上教的,但是你改了這些值, httpd 要重新啟動...
高明點用 rewrite modules: (要有 RE 的基礎)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.host\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.host\.com(.*) /home/$1$2

這樣只要新增 /home 目錄下的目錄就是新增 VirtualHost 了,且 httpd 不需重開
(有很多不同設法, http://httpd.apache.org/docs/misc/rewriteguide.html
</quote>

這一段,我拿去實做一下我的機器,發現我改成以下

RewriteEngine on
RewriteBase   /
RewriteCond   %{HTTP_HOST}                 ^test\.wu-boy\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^test\.wu-boy\.com(.*) /usr/local/www/apache22/data/test$1

我發現不會work,我把 loglevel 打開,發現他會跑無限循環

我不知道哪裡有寫錯了,有人有實做過嗎?
我覺得是

RewriteRule   ^(.+)    %{HTTP_HOST}$1          [C]

有問題,打開 logLevel

RewriteEngine on
RewriteLog "/var/log/rewrite.log"
RewriteLogLevel 3

可以 debug,可是我找不出原因

可能要麻煩大家幫忙一下了

謝謝

--
********************************************************
*               Appleboy Blog                          *
*            http://blog.Wu-Boy.com/                   *
*               Appleboy Album                         *
*             http://pic.wu-boy.com                    *
********************************************************

--
※ 發信站: 批踢踢實業坊(ptt.cc) 
◆ From: 140.123.107.41
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻