Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a domain like I need to remove www. from specified sub folder by using a .htaccess file.

Example :

  1. should redirect to

  2. All other sub folders will not redirect in url like will remain untouched.

  3. will remain untouched.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can put a rewrite rule like this in place in the .htaccess file. In this example "" is the domain name and "subdirectory" is the name of the folder for which you want to remove the "www".

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^subdirectory(\/.*)?$$1 [R=301,L]
share|improve this answer
Thanks for your answer. But it is not working because main domain and sub domain are in different server. Can you please help. – Ayan Adhikary Apr 23 '13 at 12:41
You could put that rule on the server with the subdomain. – Stephen Ostermiller Apr 23 '13 at 14:45

Just use your control panel and create a redirect without www

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.