Skip to content

Instantly share code, notes, and snippets.

@fideloper
Created June 10, 2015 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fideloper/8bc66ce0102fdc98f030 to your computer and use it in GitHub Desktop.
Save fideloper/8bc66ce0102fdc98f030 to your computer and use it in GitHub Desktop.
Apache redirect http to https
<VirtualHost *:80>
ServerName site.example.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
</VirtualHost>
<VirtualHost *:443>
ServerName site.example.com
ServerAdmin admin@example.com
DocumentRoot "/opt/local/apache2/sites/site.example.com"
DirectoryIndex index.html index.php
CustomLog /opt/local/apache2/logs/access_log combinedvhost
ErrorLog /opt/local/apache2/logs/error_log
<IfModule mod_ssl.c>
SSLEngine On
SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"
SSLProtocol -ALL +TLSv1
SSLProxyEngine On
SSLCertificateFile "...removed..."
SSLCertificateKeyFile "...removed..."
SSLCertificateChainFile "...removed..."
SSLProxyProtocol -ALL +TLSv1
SSLProxyCheckPeerCN off
#SSLProxyCheckPeerName off
</IfModule>
<Directory "/opt/local/apache2/sites/site.example.com">
Options All -Indexes -ExecCGI -Includes +MultiViews
Order allow,deny
Allow from all
AllowOverride None
<IfModule mod_dav.c>
DAV Off
</IfModule>
</Directory>
</VirtualHost>
@maneeshkush
Copy link

We hope this post helped you to find out How to Redirect HTTP to HTTPS in Apache
https://www.mstvlife.com/how-to-redirect-http-to-https-in-apache/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment