RewriteRule for ScriptAlias with mod_proxy enabled

Since my switch to Apache2+mod_proxy+mongrel, I had some troubles figuring how to make urls defined by a ScriptAlias work.

As an example, take Awstats, tipically it’s configuration involve a ScriptAlias directive in you vhost configuration.

Something like :

ScriptAlias /awstats/ /var/www/your_site_dir/cgi-bin/awstats/
<Directory /var/www/your_site_dir/cgi-bin/awstats/>
   AllowOverride All
   Options ExecCGI FollowSymLinks
   Order allow,deny
   Allow from all

But when mod_proxy is enabled, all requests are proxied, ignoring your ScriptAlias directive.

A solution if you also use mod_rewrite is to write something like this :

RewriteRule "^/awstats/.*" "$0" [PT,L]

The magic switch is PT which enable rewrite rules to be shared between differents mods.

Wed, 26 Jul 2006 17:22 Posted in

  1. By noodl 18/10/2006 at 19h52


    I suggest you see the httpd manual, in particular the docs for ProxyPass which show how to avoid proxying a uri reference below a proxied one.

    ProxyPass /awstats !
    ProxyPass / http://localhost:3000/

  2. By Tron Jonathan 23/10/2006 at 13h54

    I was aware of this solution, but mod_rewrite gives you much more flexibility.

    Thanks anyway !

Comment RewriteRule for ScriptAlias with mod_proxy enabled