Redirect to https://www.*

Redirect to https://www.*

Uberspace integrated Lets Encrypt into there system and it’s now very easy to add a free SSL certificate to your projects. As soon as you have a certificate on your website, there is no good reasons not to move every user to the https:// version of your website and disable the http:// version completely.

The easiest way to do so is to create a redirect within your configuration with .htaccess. On my projects I also redirect to the www.domain.tld subdomain. This can lead to infinite loop redirects if you’r not careful.

This one will work without a loop:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]