Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

Just use your control panel and create a redirect without www

share|improve this answer
add comment

Your Answer

 
discard

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.