Skip to content

Instantly share code, notes, and snippets.

@maxime-rainville
Created March 14, 2018 05:49
Show Gist options
  • Save maxime-rainville/91c84f3613e6f560a50152b7cfae6f45 to your computer and use it in GitHub Desktop.
Save maxime-rainville/91c84f3613e6f560a50152b7cfae6f45 to your computer and use it in GitHub Desktop.
Sample apache config to always redirect to `ServerName`
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName www.example.com
ServerAlias example.com www.example.org example.org
DocumentRoot /var/www/example
# Canonical name is important otherwise SERVER_NAME will always equals HTTP_HOST
UseCanonicalName On
RewriteEngine On
RewriteCond "%{SERVER_NAME} %{HTTP_HOST}" "!(^[^ ]*) \1" [NC]
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R=301,L]
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/chatterboxmarketing_com_au.crt
SSLCertificateKeyFile /etc/apache2/ssl/chatterboxmarketing_com_au.key
SSLCertificateChainFile /etc/apache2/ssl/chatterboxmarketing_com_au.ca-bundle
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment