301 redirect

Discussion in 'Apache' started by AHA7, Jan 10, 2007.

  1. #1
    Hello,

    I want to use 301 redirect to redirect a directory to another URL. For example, let's say that the directory I want to redirect is mydomain.com/dir1 and I want to redirect it to http://forums.digitalpoint.com/
    My question is:
    Should I create a .htaccess file that contains
    redirect 301 /dir1 http://forums.digitalpoint.com/
    Code (markup):
    and place it in the main root directory of my site (mydomain.com) or I could create a .htaccess file with the following code
    redirect 301 / http://forums.digitalpoint.com/
    Code (markup):
    and place it in the directory mydomain.com/dir1 ?
     
    AHA7, Jan 10, 2007 IP
  2. Richie_Ni

    Richie_Ni Illustrious Member

    Messages:
    10,721
    Likes Received:
    1,175
    Best Answers:
    0
    Trophy Points:
    410
    #2
    You don't need to do something in your root,just create add the following code to .htaccess file in your directory folder.
    redirect 301 /dir1 http://forums.digitalpoint.com/
    Code (markup):
     
    Richie_Ni, Jan 10, 2007 IP
  3. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You mean that I should place the .htaccess file in the directory mydomain.com/dir1 (in my example above)?
    If so, wouldn't the "/dir1" in the redirect code mean: "look for the directory named dir1 in the current directory (mydomain.com/dir1 - which has the .htaccess file) i.e. look for mydomain.com/dir1/dir1 and redirect it to http://forums.digitalpoint.com/"? Did I get it wrong?!
     
    AHA7, Jan 10, 2007 IP
  4. Richie_Ni

    Richie_Ni Illustrious Member

    Messages:
    10,721
    Likes Received:
    1,175
    Best Answers:
    0
    Trophy Points:
    410
    #4
    Oh,sorry buddy,typo!
    The code should be
    redirect  / http://forums.digitalpoint.com
    Code (markup):
    then place the .htaccess file in the dir1 folder..

    Option 2:
    Add the following code to .htaccess file located in the root
    redirect  /dir1 http://forums.digitalpoint.com
    Code (markup):

    I think either way is okay!
    Let me know if it works! :)
     
    Richie_Ni, Jan 10, 2007 IP
  5. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for your help, Richie_Ni!
    Will try it later as I don't have time right now...
     
    AHA7, Jan 10, 2007 IP