vizinho Posted May 24, 2019 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.
Flaze Posted May 24, 2019 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]
wolstech Posted May 24, 2019 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
Krydos Posted May 24, 2019 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.
Flaze Posted May 24, 2019 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now