Redirecting with a 301 for a 404

Discussion in 'All Other Search Engines' started by Yesideez, Dec 15, 2008.

  1. #1
    I've got this in my .htaccess file:
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^pictureinthesky.net [nc]
    rewriterule ^(.*)$ http://www.pictureinthesky.net/$1 [r=301,nc]
    
    ErrorDocument 404 /err404.php
    Code (markup):
    The first 4 lines I obtained with the help of a link I found on this site earlier. First I'd like confirmation that I'm doing the right thing with this bit.

    Next I've set up a custom 404 page in PHP with the following code:
    <?php
      if (!empty($_SERVER['HTTP_REFERER'])) {
        $today=date("d-M-Y H:i:s");
        $message="Date and Time: $today\nRequest URL: http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."\nReferring page: ".$_SERVER['HTTP_REFERER']."\n\nClient: ".$_SERVER['HTTP_USER_AGENT']."\nRemote IP: ".$_SERVER['REMOTE_ADDR']."\n\n";
        $message.="This is an automated message.\n\nHave a nice day.";
        @mail("MY_EMAIL_ADDRESS","Error 404",$message,"From: page404_dep@pictureinthesky.net\nReply-To: page404_dep@pictureinthesky.net");
      }
      header("HTTP/1.1 301 Moved Permanently");
      header("Location: http://www.pictureinthesky.net?re=direct");
    ?>
    Code (markup):
    Again, the majority of the code I obtained from this site earlier, I just modified it to suit my needs.

    My big question with this one is my last header() line redirecting.

    Is it OK to place ?re=direct on the URL? The reason for it is to inform the visitor on my index page that they have actually been redirected.

    EDIT: If anyone wants to see this in action, enter my website into your browser (don't want to post actual links for fear of breaking posting rules) and try and access a page that just wouldn't exist like sjdgajd.html
     
    Yesideez, Dec 15, 2008 IP
  2. johnbelly

    johnbelly Peon

    Messages:
    104
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I will try this code and i will tell u that what happen & I would like to say thanks bcz i was searching for this code.
     
    johnbelly, Dec 15, 2008 IP
  3. Yesideez

    Yesideez Peon

    Messages:
    196
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The code works perfectly fine - visitors get redirected no problem and I get emails when they do giving me all the info I need.

    I'm just wanting to know whether this is safe with the search engines having parameters on the redirect URL...

    If that isn't OK then I'll have to set up an actual 404 page.
     
    Yesideez, Dec 16, 2008 IP
  4. Yesideez

    Yesideez Peon

    Messages:
    196
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is anyone able to supply an answer to this please?
     
    Yesideez, Dec 17, 2008 IP