These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Problem with Virtualmin, Letsencrypt and redirect to https in the .htaccess file on the new forum.
Hello guys I have a small problem with Virtualmin, Letsencrypt and redirect to https in the .htaccess file.
I have included in the .htaccess the following rule to redirect sites to https:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The problem is that, I have to comment on this rule when updating Letsencrypt certificates.
Do you have any suggestions to avoid having to manually comment on the rule, keep the redirect at https and let Letsencrypt automatically update the certificate?
Thanks!
Try with this:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
Just copy/paste, it will work with any domain.
- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.
Slightly modified but it works! Thank you very much.
I've been using
RedirectMatch ^/(?!.well-known)(.*)$ https://www.example.com/$1
I just paste it at the end of Webmin -> Servers -> Apache Webserver -> Virtual Server on Port 80 -> Edit Directives.
Just as an aside, it would be nice if the FAQ on the LE website listed some of these kinds of tips.
@customsoft: Happy to see it helped with your problem. Could you post your modified solution just in case someone have same problem to be able to test both versions.
- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.