[301 Redirect] Directing Traffic from /example to /example.html

Discussion in 'Apache' started by Diablos, Sep 19, 2007.

  1. #1
    Hey guys,

    We recently changed how some parts of our website work and I need to redirect www.myurl.com/example to /example.html. Some other pages on the site still use the /example type pages so it can't be a global command that will mess up other directories

    Can anyone give me a hand here, I tried a standard format one and it didn't work.
     
    Diablos, Sep 19, 2007 IP
  2. DoA

    DoA Peon

    Messages:
    531
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    empty your /example/index.php page and put this (and only this) at in the page.

    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.myurl.com/example.html" );
    ?>
    Code (markup):
     
    DoA, Sep 19, 2007 IP
    Diablos likes this.
  3. Diablos

    Diablos Guest

    Messages:
    563
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply DOA, the problem is the new system has removed this directory, is that the reason a standard 301 didn't work?
     
    Diablos, Sep 19, 2007 IP
  4. DoA

    DoA Peon

    Messages:
    531
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, so your exisiting users are trying to visit /example/ and getting a 404 error?

    Solution - create a new directory /example/ and then create a file called index.php inside it. Then put in the code as above.

    Therefore your exisiting users with bookmarks etc will be automatically redirected to your new page.
     
    DoA, Sep 19, 2007 IP
  5. Diablos

    Diablos Guest

    Messages:
    563
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks mate :)
     
    Diablos, Sep 19, 2007 IP