Apache-2.2 – Serving Static Files Within VirtualHost Configuration

apache-2.2httpdstatic-contentweb-server

I have the following VirtualHost configuration.

<VirtualHost *:80>
        ServerName myservername.website

        <Location />
                ProxyPass http://localhost:5000/
                ProxyPassReverse http://localhost:5000/
        </Location>
</VirtualHost>

Currently there are a series of static files living in /var/www/static that the ProxyPass app is serving. I would rather that Apache served this.

I have no idea how to just say – "When a request to /static is received then serve it from /var/www/static on the filesystem". How do I do this?

Best Answer

You can use for example mod_rewrite

http://httpd.apache.org/docs/current/fr/mod/mod_rewrite.html

<VirtualHost *:80>
    ServerName myservername.website
    DocumentRoot /var/www/
    RewriteCond %{REQUEST_URI} !/static/
    RewriteRule (.*) http://localhost:5000/ [P]
</VirtualHost>