Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Example :

  1. www.example.com/blog should redirect to example.com

  2. All other sub folders will not redirect in url like www.example.com/forum will remain untouched.

  3. www.example.com will remain untouched.

share|improve this question
up vote 2 down vote accepted

You can put a rewrite rule like this in place in the .htaccess file. In this example "example.com" 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(\/.*)?$ http://example.com/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.