Last active
September 28, 2022 03:22
-
-
Save waifung0207/1a4bf1c396699b707ed5 to your computer and use it in GitHub Desktop.
Apache Virtual Host Config with HTTPS redirect and URL rewrite
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 *:80> | |
ServerName example.com | |
ServerAlias www.example.com | |
# force HTTPS | |
RewriteEngine on | |
RewriteCond %{HTTPS} off | |
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] | |
</VirtualHost> | |
<IfModule mod_ssl.c> | |
<VirtualHost *:443> | |
ServerName example.com | |
ServerAlias www.example.com | |
ServerAdmin info@website.com | |
DocumentRoot /var/www/html/website | |
ErrorLog /var/log/website/error.log | |
CustomLog /var/log/website/access.log combined | |
# SSL config | |
SSLEngine on | |
SSLCertificateFile /etc/letsencrypt/live/wildcard.example.com/fullchain.pem | |
SSLCertificateKeyFile /etc/letsencrypt/live/wildcard.example.com/privkey.pem | |
# Configuration for website with .htaccess support | |
<Directory /var/www/html/website/> | |
Options -Indexes | |
AllowOverride All | |
Require all granted | |
ServerSignature Off | |
</Directory> | |
</VirtualHost> | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment