How to Remove WWW From URL through htaccess

How to remove www from url through htaccess. Suppose, if a user type (example is the name of your domain) in their browser, you can automatically redirect them to

For website SEO (Search Engine Optimization) purpose, it is necessary that your blog or website either respond to or, but not both. Otherwise, search engines see duplicate content on the www and non-www domains, and may downgrade the site ranking.

In my previous posts, I have explained htaccess file and their importance. In this post, We will learn how to remove www from url through htaccess.

Create SEO friendly URL through .htaccess

Password protect folder through .htaccess

Prevent Image hotlinking

Subscribe Our Tutorials

Get Latest Updates on Facebook

Leverage Browser Caching

How to Remove WWW From URL through .htaccess

To remove www from Url . Put this code in your .htaccess file.

I have mentioned my domain in htaccess. You can replace and put your domain name in place of Above htaccess directives remove www from Url.

You can also use this snippet as well.

301 is HTTP status code which means permanent redirection from an old Url to a new Url. It is very important in terms of website SEO. This HTTP status code tells search engines that your site is moved from old Url to a new Url.

For example –  My website previous Url is Now, I have removed www  from website Url (, so I am using 301 . HTTP status code 301 redirect is very useful in terms of SEO as it passes the web authority of our old Url to  a new Url.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged . Bookmark the permalink.