Jump to content

Recommended Posts

Posted

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.

Posted

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]
Posted

@flazepe: I would suggest adding an exception for the .well-known folder so AutoSSL doesn't break.

RewriteCond %{REQUEST_URI} !^/.well-known
  • Like 1
Posted

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.
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...