View Single Post

  #7 (permalink)  
Old 12-15-2006
Aray
 
Posts: n/a
Default Re: Wildcard subdmoains



--

"HansH" <hansh@invalid.invalid> 写入消息
news:45813705$0$339$e4fe514c@news.xs4all.nl...
> "Aray" <1@2.3> schreef in bericht news:elrbh0$lnb$1@news.cn99.com...
>>I am trying to use module_rewrite to solve your problem, but not success
>>yet. I am newbie to apache too.
>>
>> Maybe following will give you some hints
>>
>> #try to response http://AAA.example.com/test.htm with /AAA/test.htm
>> RewriteEngine on
>> RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$
>> RewriteRule ^/(.*)$ /$1/$2
>>

> An untested thought ...
> RewriteRule ^/(.*)$ /%1/$1 [QSA,PT]
>


I tested this. It does works!

use the following configuration:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.aray\.com$
RewriteRule ^/(.*)$ /%1/$1 [QSA,PT]

Use IE request this url http://a.aray.com/file/not/exsits.htm, following log
will apears in access_log
192.168.255.254 - - [15/Dec/2006:09:18:37 +0800] "GET /a.htm HTTP/1.1" 304 -

Use Ie request this url http://a.aray.com/file/not/exsits.htm, folling log
will apears

in access_log:
192.168.255.254 - - [15/Dec/2006:09:22:14 +0800] "GET /file/not/exsits.htm
HTTP/1.1" 404 219

in error_log:
[Fri Dec 15 09:22:14 2006] [error] [client 192.168.255.254] File does not
exist: /usr/local/apache2.2/htdocs/a/file

> Still, AFAIK only functional for those FQDN specified with servername or
> serveralias witin a common vhost.
>
> HansH
>
>