virtual-host configuration for Apache HTTP

· by Tim Hughes · Read in about 1 min · (57 words)

Posting this literally so I don’t forget it.

/etc/httpd/conf.d/vhosts.conf

NameVirtualHost *
include conf.d/vhosts.d/*.conf

mkdir /etc/httpd/conf.d/vhosts.d

/etc/httpd/conf.d/vhosts.conf

NameVirtualHost *
include conf.d/vhosts.d/*.conf

/etc/httpd/conf.d/default.conf

<VirtualHost _default_:*>
    ServerAdmin [email protected]
    DocumentRoot /var/www/vhosts/default/html/
    ServerName localhost
<VirtualHost>

/etc/httpd/conf.d/vhosts.d/www.example.com.conf

<VirtualHost *:80>
    ServerName www.example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/vhosts/www.example.com/html
    RewriteEngine On
    RewriteCond %{ENV:REDIRECT_STATUS} !=503
    RewriteRule .* - [R=503,L]
    ErrorDocument 503 /index.html
    Header always set Retry-After "60"
<VirtualHost>