0

I've been looking for a way to force both https and non-www. In one set of code in .htaccess without a redirect loop.

For example:

example.com = https://example.com

Basically, anything the user types in, it goes to https://example.com.

How would I go about doing this?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • hi this code work for me `RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L,NE] RewriteCond %{HTTPS} !on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]` – jonathan May 17 '18 at 17:42

1 Answers1

1

This will take care of all combinations for your specific domain and redirect to https://example.com

RewriteEngine On
RewriteCond %{HTTPS} !^on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95