Last active
August 29, 2015 14:24
-
-
Save CTimmerman/f1e35e3666569a389ed6 to your computer and use it in GitHub Desktop.
Redirect permanently all domains to one (HTTPS) - Apache config
This file contains 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
RewriteCond %{HTTP_HOST} !^www\.company\.com$ [NC] # nocase | |
RewriteRule (.*) https://www.company.com/$1 [NE,R=301,L] # noescape, redirect, last |
This file contains 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> | |
SSLEngine on | |
SSLCertificateFile /etc/apache2/ssl/wildcard-company-com.cer | |
SSLCertificateKeyFile /etc/apache2/ssl/myserver.key | |
SSLCACertificateFile /etc/apache2/ssl/CA.cer | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} !^company\.com [NC] # nocase | |
RewriteRule ^/(.*)$ https://company.com/$1 [NE,R=301,L] # noescape, redirect, last: http://httpd.apache.org/docs/2.4/rewrite/flags.html | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.htaccess worked better for non subdomains.