satishgaudo.com

Understanding technology

Apache Virtual Host

The term Virtual Host refers to the practice of maintaining more than one server on one machine, as differentiated by their apparent hostname. For example, it is often desirable for companies sharing a web server to have their own domains, with web servers accessible as www.company1.com and www.company2.com, without requiring the user to know any extra path information.

Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both, IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

Here is the example of how to add an virtual hosts entry in your httpd.conf (/etc/httpd/conf)

<VirtualHost *:80 >
DocumentRoot /var/www/html/wwwsitefolder
#ServerName 192.168.0.66
ServerName www.satishgaudo.com
RewriteEngine On
RewriteRule ^/image/(.*)$  /image.php?do=readfile&filepath=$1
SetEnvIfNoCase Request_URI \ \.(?:gif|jpg|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
Header unset Pragma
FileETag None
<FilesMatch "\.(gif|js|css|jpg|jpe?g|png)$">
Header set Cache-Control "max-age=2592000, must-revalidate"
</FilesMatch>
CustomLog /var/log/httpd/satish_access_log combined
ErrorLog /var/log/httpd/satish_error.log
</VirtualHost>
Bookmark and Share
Categories: Apache
How I Make $300 a Day Online at 12:15 on 18 June 2009

Hey, nice post, very well written. You should post more about this.