I'm trying to force a user to be redirected to the non-www website, and, force https.
I've got this which sort of work, but doesn't force https, when http is entered.
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://site.com\.net/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^www\. RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Any ideas on what I'm doing wrong?
You can activate the feature to force HTTPS on all incoming traffic by following these steps: Go to File Manager in your hosting panel and open .htaccess inside the public_html folder. If you can’t locate it, make sure to create or unhide it. Save the changes. IMPORTANT: Make sure that the line RewriteEngine On is not repeated twice.
If it happens you couldn’t find the .htaccess file, chances are that it is hidden. To display the hidden file, click on the Settings button at the top right corner of the screen. A dialog box will pop open as soon as you click the button. In the box, check Show hidden dotfiles and click Save. You should now see the .htaccess file.
Here is what it's doing: When placed in the root .htaccess, this technique covers all requests, providing complete https/non-www canonicalization for your site. Remember to replace the two instances of example.com with your own domain name.
After installing an SSL certificate, your website is available over HTTP and HTTPS. However, it’s better to use only the latter because it encrypts and secures your website’s data. While Hostinger allows users to configure this setting in just one click, you can also use the .htaccess file to force HTTPS connection. This tutorial will show you how.
Try this rule:
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(www\.)?(.+) RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With