[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rewrite and change document root on apache



Jaume Teixi wrote:
> 
> problem is that
> 
> Document Root for each virtual host is on
>   /var/www/www.virtualhost1.com
> and I'm trying to forward http://www.virtualhost1.com/stats  to
>   /var/reports/www.virtualhost1.com
> 
> so rewrite rule
> 
> RewriteRule  ^/stats(.*)        /var/reports/%{SERVER_NAME}$1  [PT]
> 
> really looks for
>   /var/www/www.virtualhost1.com/var/reports/www.virtualhost1.com
> 
> not to
>     /var/reports/www.virtualhost1.com
> 
> how to handle this:(  ????

I'm not sure whether I understood in every detail what you are trying to
achieve -- maybe you could briefly state which document is supposed to
be served if a user requests e.g.
http://www.virtualhost1.com/stats/index.html ( is it the file
/var/reports/www.virtualhost1.com/index.html ?)

If so, the combination of rewrite and Alias (as you originally had it)
should do the job when you specify [PT] -- and only then [PT] is needed.
In this case the Alias statement may map to any path outside of the
DocumentRoot. So when using

Alias  /reports  /var/reports

the rewritten string (not the document root) would have to supply the
host part.


When using the RewriteRule alone, you would have to make sure that the
string portion, which comes out of the rewrite rule, will give the final
document path when concatenated to the DocumentRoot. For this you would
either have to use a different DocumentRoot or a different rewrite rule
to avoid getting the duplicate occurences.


-- 
Erdmut Pfeifer
science+computing gmbh

-- Bugs come in through open windows. Keep Windows shut! --



Reply to: