how to create a VirtualHost to serve only static content

deostroll picture deostroll · Jun 24, 2010 · Viewed 8.3k times · Source

I want to create a virtual host in apache such that it serves only static content like stylesheets, videos, images, javascripts, text files, etc. I am not looking at any "processing" capabilities from this virtual host.

Answer

viam0Zah picture viam0Zah · Jul 7, 2010

Create a VirtualHost entry as follows:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName media.domain.tld

    DocumentRoot "/Library/WebServer/Documents/media"

    ErrorLog "/private/var/log/apache2/media-error_log"
    CustomLog "/private/var/log/apache2/media-access_log" common

    <Directory /Library/WebServer/Documents/media>
    Order deny,allow
    Allow from all
    SetHandler default-handler
    </Directory>

</VirtualHost>