1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Trying to use .htaccess for 301 redirects

Discussion in 'Apache' started by Space Goat, Oct 4, 2005.

  1. #1
    I'm trying to use an .htaccess file to accomplish 301 redirects from my old web site, http://webpages.charter.net/jasonevines/ , to my new one, http://www.hypersyllogistic.com . (I had been using JavaScript redirects, but I've read 301's are more search engine friendly.)

    But many of the pages on my old Charter site either won't redirect, or will redirect only sometimes. :( Could the culprit be a mistake in my .htaccess file on my old complimentary Charter server?

    Here's what I have in it:

    redirect 301 /badessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/5
    redirect 301 /bush.htm http://www.hypersyllogistic.com/article.php/terracescroll/6
    redirect 301 /carpenter.htm http://www.hypersyllogistic.com/article.php/collegepapers/1
    redirect 301 /civorterr.htm http://www.hypersyllogistic.com/article.php/collegepapers/3
    redirect 301 /clinton.htm http://www.hypersyllogistic.com/article.php/terracescroll/4
    redirect 301 /common.htm http://www.hypersyllogistic.com/article.php/fparchives/1
    redirect 301 /entteen.htm http://www.hypersyllogistic.com/article.php/terracescroll/5
    redirect 301 /goreplot.htm http://www.hypersyllogistic.com/article.php/terracescroll/3
    redirect 301 /guncontrol.htm http://www.hypersyllogistic.com/article.php/terracescroll/9
    redirect 301 /impopoli.htm http://www.hypersyllogistic.com/article.php/terracescroll/1
    redirect 301 /index.htm http://www.hypersyllogistic.com/
    redirect 301 /links.htm http://www.hypersyllogistic.com/links.php
    redirect 301 /litessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/6
    redirect 301 /machiavelli.htm http://www.hypersyllogistic.com/article.php/collegepapers/5
    redirect 301 /mencken.htm http://www.hypersyllogistic.com/article.php/honorswriting/2
    redirect 301 /military.htm http://www.hypersyllogistic.com/article.php/honorswriting/4
    redirect 301 /mj.htm http://www.hypersyllogistic.com/article.php/terracescroll/8
    redirect 301 /morality.htm http://www.hypersyllogistic.com/article.php/honorswriting/3
    redirect 301 /nursing.htm http://www.hypersyllogistic.com/article.php/terracescroll/2
    redirect 301 /persessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/1
    redirect 301 /peters.htm http://www.hypersyllogistic.com/article.php/collegepapers/4
    redirect 301 /pledgesat.htm http://www.hypersyllogistic.com/article.php/satires/2
    redirect 301 /poetry.htm http://www.hypersyllogistic.com/article.php/satires/3
    redirect 301 /sat.htm http://www.hypersyllogistic.com/article.php/terracescroll/7
    redirect 301 /shatner.htm http://www.hypersyllogistic.com/article.php/satires/1
    redirect 301 /tocqueville.htm http://www.hypersyllogistic.com/article.php/collegepapers/6
    redirect 301 /writings.htm http://www.hypersyllogistic.com/writings.php
    redirect 301 /zoroastrianism.htm http://www.hypersyllogistic.com/article.php/collegepapers/2
    Code (markup):
    Thanks! :)
     
    Space Goat, Oct 4, 2005 IP
  2. briandunning

    briandunning Active Member

    Messages:
    262
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    98
    #2
    Your .htaccess file is formatted correctly and this should work. A couple of things to check:

    1. .htaccess files are notoriously sensitive to CR format. I've found that if the line breaks look good in Notepad on a PC, then you're good to go. If you made it on a Mac they are probably jacked.

    2. .htaccess support does need to be enabled in Apache, and this may be up to your ISP whether they support it or not. Check their FAQ's.

    Just my two cents, others may have better ideas.
     
    briandunning, Oct 4, 2005 IP
  3. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If your files will redirect sometimes then that would suggest that your old host does support .htaccess, and if there was corruption in the .htaccess file I would expect all your old pages to return a 500 Server Error.
    When you say that some pages will only redirect sometimes, what happens the rest of the time ? Do the old pages serve, do you get an error, etc ?

    If a particular page sometimes redirects correctly and sometimes serves the old page, that sounds like there are multiple copies of your website, and specifcally of the .htaccess file. Could your old host be load-balancing somehow such that the files for your site exist on more than 1 machine ? If they are transparently load-balancing and synchronising file changes across different machines you may have to wait until the files have been synchronised and then everything will work fine.
    If your redirection is still not working after a day, maybe, then I would get in touch with the old host and ask them what's going on.

    You could also try installing something to enable you to look at the HTTP headers which are sent with a page, that might tell you something. If you're running FireFox there's an extension called LiveHeaders or Live HTTP Headers or something ( don't have the link to hand I'm afraid ) that would do the job.

    cheers

    johnt
     
    johnt, Oct 4, 2005 IP
  4. Space Goat

    Space Goat Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The old pages appear, without redirecting anywhere.

    I've downloaded it, but it doesn't seem to tell me anything. :confused:
     
    Space Goat, Oct 4, 2005 IP
  5. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hmm, if the old pages appear it does sound like there's multiple copies of your .htaccess file being served.
    I'd check with your host.

    The Live Headers extension allows you to capture and examine the HTTP headers which will show you the HTTP response code, cookies etc. The response code can be helpful when trying to track down these sorts of error, but in this case it sounds like you probably get a 200 ( OK ) response, so it wouldn't help.

    Check with your hosting company.
     
    johnt, Oct 5, 2005 IP
  6. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi
    is this .htaccess here webpages.charter.net/jasonevines/
    because if not if it is in root it wont work have to extend to

    /jasonevines/badessay.htm whatever to

    expat
     
    expat, Oct 5, 2005 IP
  7. Space Goat

    Space Goat Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I tried that, but it still doesn't work.

    Besides in, in my FTP program, my single directory isn't /jasonevines/, it's /.
     
    Space Goat, Oct 5, 2005 IP
  8. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Besides in, in my FTP program, my single directory isn't /jasonevines/, it's /.

    that maybe but the site structure is domain/subdir/subdir/....

    which is in unix speak translated to ~/www/subdir/subdir etc

    thus when you set the host folder on ftp to /subdir/ you only see and access whats in subdir not what is in domain root.

    .htaccess is processed like css cascading
    e.g. if root has .htaccess this is processed first than if there is a .htaccess in subdir this is processed next.... etc

    I also assume that you have the following top entries just in case

    RewriteEngine on
    Options +FollowSymLinks

    as your host may have switched off rewrite engine
    Symlinks allows for transparent sub structure to be processed.

    Check top level .htaccess than next level and so on

    Expat
     
    expat, Oct 5, 2005 IP
  9. Space Goat

    Space Goat Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Here is what I have now:

    RewriteEngine on
    Options +FollowSymLinks
    
    redirect 301 /jasonevines/badessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/5
    redirect 301 /jasonevines/bush.htm http://www.hypersyllogistic.com/article.php/terracescroll/6
    redirect 301 /jasonevines/carpenter.htm http://www.hypersyllogistic.com/article.php/collegepapers/1
    redirect 301 /jasonevines/civorterr.htm http://www.hypersyllogistic.com/article.php/collegepapers/3
    redirect 301 /jasonevines/clinton.htm http://www.hypersyllogistic.com/article.php/terracescroll/4
    redirect 301 /jasonevines/common.htm http://www.hypersyllogistic.com/article.php/fparchives/1
    redirect 301 /jasonevines/entteen.htm http://www.hypersyllogistic.com/article.php/terracescroll/5
    redirect 301 /jasonevines/goreplot.htm http://www.hypersyllogistic.com/article.php/terracescroll/3
    redirect 301 /jasonevines/guncontrol.htm http://www.hypersyllogistic.com/article.php/terracescroll/9
    redirect 301 /jasonevines/impopoli.htm http://www.hypersyllogistic.com/article.php/terracescroll/1
    redirect 301 /jasonevines/index.htm http://www.hypersyllogistic.com/
    redirect 301 /jasonevines/links.htm http://www.hypersyllogistic.com/links.php
    redirect 301 /jasonevines/litessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/6
    redirect 301 /jasonevines/machiavelli.htm http://www.hypersyllogistic.com/article.php/collegepapers/5
    redirect 301 /jasonevines/mencken.htm http://www.hypersyllogistic.com/article.php/honorswriting/2
    redirect 301 /jasonevines/military.htm http://www.hypersyllogistic.com/article.php/honorswriting/4
    redirect 301 /jasonevines/mj.htm http://www.hypersyllogistic.com/article.php/terracescroll/8
    redirect 301 /jasonevines/morality.htm http://www.hypersyllogistic.com/article.php/honorswriting/3
    redirect 301 /jasonevines/nursing.htm http://www.hypersyllogistic.com/article.php/terracescroll/2
    redirect 301 /jasonevines/persessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/1
    redirect 301 /jasonevines/peters.htm http://www.hypersyllogistic.com/article.php/collegepapers/4
    redirect 301 /jasonevines/pledgesat.htm http://www.hypersyllogistic.com/article.php/satires/2
    redirect 301 /jasonevines/poetry.htm http://www.hypersyllogistic.com/article.php/satires/3
    redirect 301 /jasonevines/sat.htm http://www.hypersyllogistic.com/article.php/terracescroll/7
    redirect 301 /jasonevines/shatner.htm http://www.hypersyllogistic.com/article.php/satires/1
    redirect 301 /jasonevines/tocqueville.htm http://www.hypersyllogistic.com/article.php/collegepapers/6
    redirect 301 /jasonevines/writings.htm http://www.hypersyllogistic.com/writings.php
    redirect 301 /jasonevines/zoroastrianism.htm http://www.hypersyllogistic.com/article.php/collegepapers/2
    Code (markup):
    It still doesn't seem to work. :confused:
     
    Space Goat, Oct 5, 2005 IP
  10. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #10
    but your ftp is to /
    and pages you load show in whateverdomain.com/jasonevines/newpage.htm

    so you loading this .htaccess effectively to whateverdomain.com/jasonevines/.htaccess

    change one line

    redirect 301 badessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/5

    try that page

    cheers
    Martin
     
    expat, Oct 5, 2005 IP
  11. Space Goat

    Space Goat Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    No change.

    Also, I've found that the Web Developers Toolbar provides header information. All the pages produce 200 headers.
     
    Space Goat, Oct 5, 2005 IP
  12. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I think you can't run .htaccess on this server as I can access it from the outside.

    I can only think of two options ask the hosting to do a generic 301 for you

    and you can do another detailed 301 on your new host (if they allow this)

    as you already run mod_rewrite there at the end would be the list
    redirect 301 badessay.htm http://www.hypersyllogistic.com/article.php/honorswriting/5

    I assume your htm pages won't process php so a php redirect is out

    you can try - it looks like this top of page

    <?php
    // Permanent redirection
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.somacon.com/");
    exit();
    ?>
    Neither Java nor Html meta refresh do send a 301 so it's worth persuing this.As I said sorry I'm out ofoptions hopefully somone else can helpExpat
     
    expat, Oct 5, 2005 IP
  13. Space Goat

    Space Goat Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I just called Charter, who is providing the old webspace, and I was told they don't support any server-side scripting or usage of Apache services. So are 301 redirects just denied to me then? :(
     
    Space Goat, Oct 5, 2005 IP
  14. briandunning

    briandunning Active Member

    Messages:
    262
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    98
    #14
    Since you can't use any of the above methods, as far as I know you are out of luck. Hopefully someone else will chime in with another option. :(
     
    briandunning, Oct 5, 2005 IP