Redirect to HTTPS with ServerAlias

From InToSSH's Tutorials & Scripts
Jump to navigation Jump to search

If you have VirtuaHost that has both the ServerName and ServerAlias when you use LetsEncrypt and you want both of those URLs to redirect to HTTPS, the Rewrite will look like this

RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]