apache2 force proxy for specific url on a subdomain

Posted by Tony G. on Server Fault See other posts from Server Fault or by Tony G.
Published on 2009-09-06T17:45:37Z Indexed on 2010/03/25 13:03 UTC
Read the original article Hit count: 553

Hi,

I have a site that has dynamic virtual subdomains using mod_rewrite, as defined like this:

<VirtualHost *:80>
    ServerName    example.com
    ServerAlias    *.example.com

    DocumentRoot    /var/www/example.com/www

    RewriteEngine    on
    RewriteCond    %{HTTP_HOST}    ^[^.]+\.examle.com$
    RewriteRule    ^(.+)            %{HTTP_HOST}$1    [C]

    RewriteRule    ^([^.]+)\.example.com(.*)    /var/www/example.com/$1$2

</VirtualHost>

The problem is that I want a specific url, say subdomain.example.com/CONTROL/ to point back to www.example.com/ using a proxy (not url redirecting).

I have tried adding:

RewriteRule ^([^.]+)\.example.com/CONTROL(.*)    /var/www/example.com/www$2 [P]

But that didn't work. Any ideas?

© Server Fault or respective owner

Related posts about virtual-hosts

Related posts about mod-rewrite