Skip to content

Instantly share code, notes, and snippets.

@mattclements
Last active April 14, 2018 17:58
Show Gist options
  • Save mattclements/47446c5eb1fc9b6eff9f to your computer and use it in GitHub Desktop.
Save mattclements/47446c5eb1fc9b6eff9f to your computer and use it in GitHub Desktop.
Apache VHOST File
ServerName [% vhost.servername %]
[% IF vhost.serveralias_array.size -%]
[% FOREACH alias IN vhost.serveralias_array -%]
ServerAlias [% alias %]
[% IF alias == 'www.' _ vhost.servername -%]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
[% END -%]
[% END -%]
[% ELSE -%]
ServerAlias [% vhost.serveralias %]
[% IF vhost.serveralias == 'www.' _ vhost.servername -%]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
[% END -%]
[% END -%]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment