Created
March 14, 2018 05:49
-
-
Save maxime-rainville/91c84f3613e6f560a50152b7cfae6f45 to your computer and use it in GitHub Desktop.
Sample apache config to always redirect to `ServerName`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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