Results 1 to 8 of 8
  1. #1
    Full Member
    Join Date
    January 18th, 2005
    Posts
    88
    I have a 404 page defined in htaccess.
    I want to pass the referer page of the 404.php ( i.e. the file name which is not found) as a parameter in 404.php
    -----
    ErrorDocument 404 http://www.mydomain.com/404.php?ref={$HTTP_REFERER}
    -----

    The above is not working.
    I am wondering why?

  2. #2
    pph Expert! Gordon's Avatar
    Join Date
    January 18th, 2005
    Location
    Edmonton Canada
    Posts
    5,781
    I use this and it gives me the page that was requested

    .getenv("REQUEST_URI")
    One day parasites and their ilk will be made illegal, I bet a few Lawyers will be pissed off when the day comes.
    Mr. Spitzer is fetching it nearer

    YouTrek

  3. #3
    ABW Ambassador CrazyGuy's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,463
    htaccess doesn't act like a web browser/server - so the http_referrer environment variable means nothing to it, so it can't pass it along to your 404 script.

    I do mine in perl so I can't help with the syntax, but as Gordon suggests, you should be able to pick up the referrer in the 404 script itself, bouncing the hit off htaccess shouldn't have got in the way of that.

  4. #4
    Full Member
    Join Date
    January 18th, 2005
    Posts
    88
    I have tried every available method.
    Since I use url rewrite very often, the referer is not correctly passed in 404.php page.

    Any more inputs would be appreciated.

  5. #5
    Full Member
    Join Date
    January 18th, 2005
    Posts
    88


    I think I got the solution.

    Tried
    foreach($_SERVER as $a=>$b) print "$a - $b<br>";

    and the result lies in Server["REDIRECT_URL"]
    And I should not have written like this

    ErrorDocument 404 http://www.test.com/404error.php
    instead it should have been
    ErrorDocument 404 /404error.php

    testing it now.

    Thanks for your help.

  6. #6
    pph Expert! Gordon's Avatar
    Join Date
    January 18th, 2005
    Location
    Edmonton Canada
    Posts
    5,781
    put this on your 404 page (php) it works for me.

    <?
    //Page that wasn't found
    $requestedfile=$websiteaddress.getenv("REQUEST_URI");
    ?>

    Sorry the page you have requested, <?echo $requestedfile;?>, no longer exists in our website.
    One day parasites and their ilk will be made illegal, I bet a few Lawyers will be pissed off when the day comes.
    Mr. Spitzer is fetching it nearer

    YouTrek

  7. #7
    Newbie
    Join Date
    June 11th, 2010
    Posts
    1
    Sorry, but I am new in this industry.. I am actually planning to create my own web, and actually seen this kind of error.. Anyone who has a tutorial, or even can give me a link to make me understand things better? Thanks in advance..

  8. #8
    ABW Ambassador 2busy's Avatar
    Join Date
    January 17th, 2005
    Location
    Tropical Mountaintop
    Posts
    5,636
    Welcome to ABW Daniella, you can learn it all step by step for free at http://www.w3schools.com/
    You might want to check the date of the thread you are posting in as this one is 6 years old. A lot of times you can get outdated information in old threads, and it's not appreciated very much when these oooold topics get bumped to the top again with a new post.

  9. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Passing referer including keywords to merchant
    By opalepatrick in forum Programming / Datafeeds / Tools
    Replies: 11
    Last Post: May 21st, 2010, 04:18 PM
  2. url masking using htaccess or php redirect
    By breeke in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: April 29th, 2010, 07:48 PM
  3. How do I make PHP generate a 404 page when products no longer exist?
    By Leader in forum Programming / Datafeeds / Tools
    Replies: 9
    Last Post: May 9th, 2005, 04:06 AM
  4. 404 page
    By SSanf in forum Programming / Datafeeds / Tools
    Replies: 4
    Last Post: March 1st, 2003, 10:04 AM
  5. Search box on 404 page?
    By Ray in forum Programming / Datafeeds / Tools
    Replies: 13
    Last Post: November 21st, 2002, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •