So I want to redirect example.com
to https://www.example.com
. I already have ssl with certbot but I want to change my redirect config in /etc/apache2/sites-available/example.conf
.
Certbot already gives you a redirect from example.com
to https://example.com
.
this is my current apache config
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>