vizinho Posted May 24, 2019 Share Posted May 24, 2019 Hello! I want the website address to always be converted to the "https and non-www" kind.Even if the user is landing on a page that is not homepage. Can you point me the good code to use on .htaccess or any other good method? Thanks. Quote Link to comment Share on other sites More sharing options...
flazepe Posted May 24, 2019 Share Posted May 24, 2019 You have the same preference as mine. Here's the code: # REDIRECT EVERYTHING TO HTTPS AND WITHOUT WWW RewrinteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule .* https://%1%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule .* https://%1%{REQUEST_URI} [R=301,L] Quote Link to comment Share on other sites More sharing options...
wolstech Posted May 24, 2019 Share Posted May 24, 2019 @flazepe: I would suggest adding an exception for the .well-known folder so AutoSSL doesn't break. RewriteCond %{REQUEST_URI} !^/.well-known 1 Quote Link to comment Share on other sites More sharing options...
vizinho Posted May 24, 2019 Author Share Posted May 24, 2019 Thank you both.Seems to be working fine! Quote Link to comment Share on other sites More sharing options...
Krydos Posted May 24, 2019 Share Posted May 24, 2019 Anyone who searches and finds this you'll also need to add the line RewrinteEngine On before all the other code listed above or else it won't work. Quote Link to comment Share on other sites More sharing options...
Luigi123 Posted May 24, 2019 Share Posted May 24, 2019 Moved to “Customer Service”. Quote Link to comment Share on other sites More sharing options...
flazepe Posted May 24, 2019 Share Posted May 24, 2019 Anyone who searches and finds this you'll also need to add the line RewrinteEngine On before all the other code listed above or else it won't work.Thanks, it was way on top of the file. Fixed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.