Jump to content

[Solved] https and non-www


vizinho

Recommended Posts

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.

Link to comment
Share on other sites

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]
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...