Add HTTPS Redirect to htaccess?
Hi
I have the following generated by cPanel (if I get it right), and need to redirect all site (pages) to https.
I used to add this to achieve it
but now I don't know if I can just add the above to the generated one, or should I change something. Note: The myseconddomain is not active anymore. Thank you
=========
RewriteEngine on
# www
rewritecond %{http_host} ^mysite.com [nc]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/.+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]
RewriteCond %{HTTP_HOST} ^myseconddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.myseconddomain\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/.+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/mysite\.com" [R=301,L]
=========
I used to add this to achieve it
=========
RewriteEngine On
RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
=========
but now I don't know if I can just add the above to the generated one, or should I change something. Note: The myseconddomain is not active anymore. Thank you
-
Hi @keneso It looks like all this does is rewrite mysite.com and myseconddomain to [plain]http://www.mysite.co [/plain] and [plain] http://www.myseconddomain.com[/plain] which if you're adding a forced redirect to[plain] https://www.mysite.com[/plain] are no longer needed. The cPanel inserted directives will be automatically added again if there's an issue with the DCV check when AutoSSL runs again. With that being said I'd just remove that whole block in place of your new redirect. If you're concerned you can add comments to it before completely removing it to test it out. 0 -
Thank you. Will do as suggested. 0
Please sign in to leave a comment.
Comments
2 comments