httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Dessent <>
Subject Re: [users@httpd] Help me please .. Mod_rewrite
Date Mon, 02 Feb 2004 14:18:09 GMT
Jerome Schevingt wrote:

> - - [02/fév/2004:13:04:35 +0100]
> [][rid#8fc74f0/initial] (2) init rewrite
> engine with requested uri /clients/
> - - [02/fév/2004:13:04:35 +0100]
> [][rid#8fc74f0/initial] (3) applying pattern
> '^/clients/(.+)$' to uri '/clients/'
> - - [02/fév/2004:13:04:35 +0100]
> [][rid#8fc74f0/initial] (2) rewrite
> /clients/ ->
> - - [02/fév/2004:13:04:35 +0100]
> [][rid#8fc74f0/initial] (3) split
> uri= ->
> uri=,
> - - [02/fév/2004:13:04:35 +0100]
> [][rid#8fc74f0/initial] (2) forcing
> proxy-throughput with
> - - [02/fév/2004:13:04:35 +0100]
> [][rid#8fc74f0/initial] (1) go-ahead with
> proxy request proxy: [OK]

The above is the first request.  It looks fine.  The next request is for
/clients/ as you noted, and that's not right.

I think the problem you're having is due to how AWstats works.  It
expects to be able to construct self-referential (relative) URLs.  For
example, if you look at what it returns from loading
"/cgi-bin/", it returns a frameset, similar to the

<frame name="mainleft" src="">
<frame name="mainright" src="">

Additionally, the links within the stats pages are also relative URLs of
the form

<a href="">

When the browser tries to load one of these such links, it thinks the
current URL is

...and so when it sees a relative link such as the above, it tries to
request it as

...because /clients/ is the current directory.  So you need to add a
rule to pass through these calls to, and anything else in
/cgi-bin/ that Awstats would refer to.  Try something like this:

RewriteEngine On
RewriteRule ^/clients/awstats\.pl$ \ [P]
RewriteRule ^/clients/([0-9A-Za-z.-]+)$ \$1 [P]

Note that the \ on the end is for readability in email, you'd make those
all on one line in your config.  Also remember that the order of the two
is important, since requests for "/clients/" will match either
line, but you want it handled by the first one.

I changed your regexp a little because it's safer.  If you know that a
domain name must come after /clients/ then have it only match against
valid domain characters.  Otherwise you might accidently open yourself
up to mischief since mod_rewrite will pass on anything after the
"/clients/" part without checking it at all.  In this case it shouldn't
matter since the $1 is being put in the query string and not the URI
part of the request.

Also, if there are any other URLs in the Awstats output (such as image
files) then you will also have to make provisions to reverse-proxy them
as well.  For example, if the Awstats output contains things such as:

<img src="/images/awstats/something.png">

Then you will need to do something like the following in your virtualhost:

ProxyPass /images/awstats/ \
ProxyPassReverse /images/awstats/ \

ProxyPass is more or less the same as using mod_rewrite with the [P],
except that it should be slightly more efficient if you are mirroring
paths or subdirectories without changing the layout.  ProxyPassReverse
is good to use also since it will rewrite any URLs in the Location field
if a Redirect is used by the site being proxied.  In the case of images
it's probably not necessary.

Alternatively, you could copy over the images into the docroot of the
stats vhost and not bother proxying them.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message