Need help with 301 redirect! My My website won't work...

Discussion in 'Apache' started by robin_west, Dec 11, 2010.

  1. #1
    Hi!

    I urgently need help to fix a problem with my 301 redirection using a .htaccess file..

    I recently bought a new domain and I can't get my old site to redirect to the new one. What I need to do is that I need to redirect permanently:

    http://myoldsite(dot)com to http://mynewsite(dot)com
    http://myoldsite(dot)com/oldpagename.html to http://mynewsite(dot)com/newpagename.html (same content though just changing the page name)

    So what I need to do is redirect the home page and my 7 other pages to the new domain with a few pages changing names too. How should the .htaccess file code look like?

    Please help I want this to be fixed. :(
     
    robin_west, Dec 11, 2010 IP
  2. marsh_candy

    marsh_candy Active Member

    Messages:
    183
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    marsh_candy, Dec 11, 2010 IP
  3. susan_ham

    susan_ham Peon

    Messages:
    352
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I agree with marsh_candy, the method he gives is really a easy method for redirection. Of course, you also can use permanent to replace 301 in that two lines.
     
    susan_ham, Dec 11, 2010 IP
  4. PeterTaylor

    PeterTaylor Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Out of interest does anyone know if its possible to do this without entering the full domain?.
    i.e. i could never get the below to work:

    Redirect 301 /contact.htm contact.php
    or
    Redirect 301 /contact.htm /contact.php

    I always found i had to use the full domain with http i.e.:

    Redirect 301 /contact.htm http://
     
    PeterTaylor, Dec 11, 2010 IP
  5. robin_west

    robin_west Member

    Messages:
    112
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #5
    I've tried that. But it won't work. Should I have any other codes in my .htaccess file before this code or can it be blank? Also where in my server should I upload the file? In the root where all my website's folders are or in the folder of the old domain? (i use filezilla so instructions would be nice too :D)
     
    robin_west, Dec 12, 2010 IP
  6. PeterTaylor

    PeterTaylor Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Robin

    There should be no other codes/lines.

    1) Copy and paste the below 5 lines into a text file and save it as file
    .htaccess
    Note it has no file name, just the extension .htaccess
    Change the below last part of each line to your new website domain:

    Redirect 301 /index.htm http:// yournewdomainincludingwww
    Redirect 301 /index.html http:// yo urnewdomainincludingwww
    Redirect 301 /default.htm http:// yournewdomainincludingwww
    Redirect 301 /default.html http:// you rnewdomainincludingwww
    Redirect 301 /index.php http:// yo urnewdomainincludingwww

    So you now have a file called .htaccess containing only the above 5 lines

    2) Upload the .htaccess file to your root folder of your old website/domain using filezilla. The root folder might be called something like htdocs. I am assuming you currently have 2 websites old and new and both are up and running ie you havent cancelled the hosting/webspace on the old website

    3) If the above still does not work contact your isp giving them the above information to check .htaccess is allowed/enabled on your webspace.

    Hope this helps
     
    Last edited: Dec 12, 2010
    PeterTaylor, Dec 12, 2010 IP