Redirecting root and www to sub-folder .. Need Help

Discussion in 'Apache' started by Ricky, Jul 11, 2008.

  1. #1
    I was doing simple 301 redirect earlier to redirect my sites root to a sub folder but today I found that it was actually also redirecting subdomain too..
    old redirect I was using :
    redirect 301 /index.php http://www.domain.com/subfolder/
    Code (markup):
    So I decided to get rid of it and now I want to redirect
    www.domain.com and domain.com to be redirected to :
    www.domain.com/subfolder/

    I used following but it is only redirecting "domain.com" to "www.domain.com/subfolder/" but not redirecting "www.domain.com" to "www.domain.com/subfolder" ...

    RewriteCond %{http_host} ^domain.com$ [nc]
    Rewriterule ^(.*)$ http://www.domain.com/subfolder/$1 [r=301,nc]
    
    Code (markup):
    Kindly guide..
     
    Ricky, Jul 11, 2008 IP
  2. wattie

    wattie Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    what about the following:

    
    RewriteCond %{http_host} ^www.domain.com$ [NC,OR]
    RewriteCond %{http_host} ^domain.com$ [NC]
    Rewriterule ^(.*)$ http://www.domain.com/subfolder/$1 [R=301,NC]
    
    Code (markup):
     
    wattie, Jul 15, 2008 IP
  3. Ricky

    Ricky Active Member

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    Hi.. man.. I tried that too but problem ws that it won't let any other folder work.. ie. if I try to open www.domain.com/anyotherfolder then it won't .

    In short any other folder than /subfolder is not working.. :(
     
    Ricky, Jul 22, 2008 IP