user3703456
user3703456

Reputation:

.htaccess - redirect all to non-www

How to redirect all pages to non-www https?

http://example.com/* -> https://example.com/*
http://www.example.com/* -> https://example.com/*

https://www.example.com/* -> https://example.com/*

Thanks

Upvotes: 1

Views: 303

Answers (1)

Croises
Croises

Reputation: 18671

Use:

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

Upvotes: 2

Related Questions