Redirect root traffic to new folder without affecting other folders

Discussion in 'Site & Server Administration' started by AccidentReport, Mar 19, 2008.

  1. #1
    I've been trying to work out how to redirect traffic comming to my site into a new folder.

    Originally I had all my pages in the root directory but as I've added new domains and sub-domains to my space it's gotten a bit untidy and so i want to move my root files into a seperate foledr so that nothing gets mixed up.

    I've tried using an htaccess redirect:
    RedirectMatch permanent ^/$ http://mydomain.com/php/index.php
    Code (markup):
    but this redirects ANY traffic to the new location. What I want is a way to redirect the root traffic but leave the sub-domain traffic alone. I'm aware that I could use a META refresh to do it but that's just a bit untidy and I'm sure there must be a better way than that.

    Appreciate the help!
     
    AccidentReport, Mar 19, 2008 IP
  2. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:
    Options +FollowSymlinks
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^www.mydomain.com$
    RewriteRule ^$ http://mydomain.com/php/index.php [R=301]
    
    Code (markup):
    Jean-Luc
     
    Jean-Luc, Mar 19, 2008 IP
  3. AccidentReport

    AccidentReport Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    worked a treat. Thanks a lot!
     
    AccidentReport, Mar 20, 2008 IP