-2

I have a domain which is accessible on http://www.example.com.

I want to remove the www. part. I am using a .htaccess file, but it isn't working.

 RewriteEngine On

 RewriteCond %{HTTPS} off [OR]
 RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301,NE]
TRiG
  • 10,148
  • 7
  • 57
  • 107
  • possible duplicate of [.htaccess Remove WWW from URL + Directories](http://stackoverflow.com/questions/6515081/htaccess-remove-www-from-url-directories) (the **first** result on Google for "*htaccess remove www*") – h2ooooooo Oct 02 '14 at 11:16
  • What's "not working" about it? – Rowland Shaw Oct 02 '14 at 11:16
  • This question appears to be off-topic because it is aimed at [webmasters](http://webmasters.stackexchange.com) – Rowland Shaw Oct 02 '14 at 11:17

1 Answers1

3

Place this rule in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} www\.
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301,NE]
TRiG
  • 10,148
  • 7
  • 57
  • 107