1

This code did not work for me:

RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC]
RewriteRule ^(.*) http://mydomain.com/$1 [L,R=301]

I have tested a lot of things including Generic htaccess redirect www to non-www, but it did not solved my problem.

Can any body help me to solve this problem ?

Community
  • 1
  • 1
Onkar Janwa
  • 3,892
  • 3
  • 31
  • 47

2 Answers2

0
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
0

I solved it using

RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC]
RewriteRule .* http://mydomain.com%{REQUEST_URI} [R=301,L]
Onkar Janwa
  • 3,892
  • 3
  • 31
  • 47