Home htaccess Redirect www to non-www in .htaccess
Redirect www to non-www in .htaccess

Redirect www to non-www in .htaccess

In my previous post I mentioned how to redirect non-www to www in htaccess. Now I’ll give codes how to redirect www to non-www in .htaccess

Open your .htaccess file and add the code below.

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

Important: add RewriteEngine On at the top of your .htaccess if you don’t have it.


Related posts

Write a comment

Sign up for our newsletters.

Do you want to see our new posts?

Enter your email below to get our latest posts! (NO SPAM!)