0

I want that a url of the form

http://www.example.com

redirects to

example.com

How can I achive this? I found that .htaccess Remove WWW from URL + Directories comes pretty close to my question, but I do not know how to change it appropriately.

Community
  • 1
  • 1
Adam
  • 25,960
  • 22
  • 158
  • 247

1 Answers1

0

To remove www ,you can use :

RewriteEngine on


RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R]

or

RewriteEngine on


RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [NE,L,R]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115