Need help with 301 redirects

Discussion in 'Site & Server Administration' started by JosephPreston, Aug 1, 2010.

  1. #1
    Hello, I am having one of those days where my brain just isn't working.

    I own the domain "systemforex.ca"

    I want to use .htaccess to redirect it to sniper.systemforex.ca/trading/ upon entry. Obviously to add more keywords to the address and to better target what I advertise.

    I can't seem to redirect the domain path systemforex.ca to the sub-domain. OR redirect the sub-domain to the directory /trading/ (sniper.systemforex.ca/trading/)

    Thus far i have tried every code i can find but nothing will do what I want. To sum it up easily. I want both systemforex.ca and sniper.systemforex.ca to redirect to sniper.systemforex.ca/trading/ - I can't get the job done without running into issues, but i definitely prefer using 301's over anything else.

    Any suggestions ?
     
    JosephPreston, Aug 1, 2010 IP
  2. JosephPreston

    JosephPreston Greenhorn

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    This was a confusing task as I had to use a .htaccess in both directories, I knew that before hand, and initially i thought i had to use two different codes, but in the end I only had to modify the same code i used for the domain path to fit the sub-domain.

    So the end result was this for the domain path.

    RewriteEngine On
    Options +FollowSymlinks
    RewriteCond %{HTTP_HOST} ^(www\.)?systemforex\. ca$ [NC]
    RewriteRule ^ http://www.sniper.mydomain.ca/trading/ [R,L]

    And for the sub:

    RewriteEngine On
    Options +FollowSymlinks
    RewriteCond %{HTTP_HOST} ^(www\.)?sniper\.systemforex\.ca$ [NC]
    RewriteRule ^ http://www.sniper.mydomain.ca/trading/ [R,L]

    My idea to had the sniper\. to the first code to see if it works. So I tried it and it works and also shows as a SEO friendly redirect. I don't know why i didn't try that first. Told you my brain wasn't working. All is well.
     
    JosephPreston, Aug 1, 2010 IP