Redirect subdomain with www. to non-www

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

We’ve heard a lot about redirecting the primary site with www to non-www. Well, this article is going to show you steps on how to redirect a subdomain with www to a non-www subdomain.

There is almost a similar redirect that we need to put in for the Subdomain like we did on the primary site using the heart of our site i.e. .htaccess file.

Issue

How to redirect subdomain with www prefix to a non-www prefix url. Ex: http://www.subdomain.maindomain.com to http://subdomain.maindomain.com

Resolution

Add the following line of code in .htaccess file usually found in the root of your website file structure.

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

If you face any difficulty while deploying this fix, drop me a line and I will be happy to help you. 

Did you find it helpful? Drop a line and share it forward to help others. Have a nice day.

Get in Touch

Contact me for work opportunities

Follow Me

facebook color   google plus color linkedin color youtube color twitter color