Skip to content

Instantly share code, notes, and snippets.

@aseredenko
Last active October 15, 2018 11:07
Show Gist options
  • Save aseredenko/5a00aafded59129debab27821874c9e4 to your computer and use it in GitHub Desktop.
Save aseredenko/5a00aafded59129debab27821874c9e4 to your computer and use it in GitHub Desktop.
Define SITE sitename.com
Define NAME sitename
<VirtualHost *:80>
ServerName ${SITE}
ServerAlias www.${SITE}
ServerAdmin webmaster@localhost
DocumentRoot /home/deploy/sites/${NAME}/web
ErrorLog ${APACHE_LOG_DIR}/${SITE}.error.log
CustomLog ${APACHE_LOG_DIR}/${SITE}.log combined
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
<VirtualHost *:443>
ServerName ${SITE}
ServerAlias www.${SITE}
ServerAdmin webmaster@localhost
DocumentRoot /home/deploy/sites/${NAME}/web
RewriteEngine On
RewriteCond %{HTTP_HOST}s !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorLog ${APACHE_LOG_DIR}/${SITE}.error.log
CustomLog ${APACHE_LOG_DIR}/${SITE}.access.log combined
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/www_${NAME}_com.crt
SSLCertificateKeyFile /etc/apache2/ssl/${NAME}.com.key
SSLCertificateChainFile /etc/apache2/ssl/www_${NAME}_com.ca-bundle
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment