Skip to content

Instantly share code, notes, and snippets.

@avtarnanrey
Last active May 6, 2020 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avtarnanrey/f65951517aa3a71ce13231e6a4786d1d to your computer and use it in GitHub Desktop.
Save avtarnanrey/f65951517aa3a71ce13231e6a4786d1d to your computer and use it in GitHub Desktop.
Common apache config to redirect http to https and setting SSL certificate and allow .httaccess settings
<VirtualHost *:80>
Redirect "/" "https://your_website.com"
</VirtualHost>
<VirtualHost *:443>
ServerAdmin avtar@avtarnanrey.com
ServerName your_website.com
ServerAlias www.your_website.com
DocumentRoot /var/www/your_website.com
ErrorLog ${APACHE_LOG_DIR}/website_error.log
CustomLog ${APACHE_LOG_DIR}/website_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/your_website.pem
SSLCertificateKeyFile /etc/ssl/private/your_website.key
#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
#SSLCACertificatePath /etc/ssl/certs/
#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt
#SSLCARevocationPath /etc/apache2/ssl.crl/
#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl
#SSLVerifyClient require
#SSLVerifyDepth 10
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
# BrowserMatch "MSIE [2-6]" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
<Directory /var/www/your_website.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment