SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I'm making a custom 404 page.

    I have htaccess redirect 404's to http://www.hiphopmusic.co.uk/index.php?missing=1

    However, echoing $REQUEST_URI simply echos "?missing=1", and not the reffering page.

    What do i need to do

    cheers
    James

  2. #2
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, it should do.

    Try this instead:

    echo $SCRIPT_NAME.'?'.$QUERY_STRING;

    OR

    echo getenv( 'SCRIPT_NAME' ).'?'.getenv( 'QUERY_STRING' );

    The second version is for systems where the ENV variables are not made into globals.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use $HTTP_REFERER will give you the referring page.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  4. #4
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, I completly mis-read that one. Guess I should slow down and sleep more, it might help.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  5. #5
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $HTTP_REFERER does not seem to work either :

    http://www.hiphopmusic.co.uk/sdfsdfsdf.html

    it should be echoed on index.php here .....link () which ...... between the brackets.

    J

  6. #6
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does work!
    When I clicked the link, it showed this thread's URL.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  7. #7
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Maybe James wants the bad URL echoed? Here's how we do it at SitePoint:

    Code:
    $thisurl = $SERVER_NAME . $REDIRECT_URL;
    if ($REDIRECT_QUERY_STRING) 
    {
    	$fullurl = $thisurl . $REDIRECT_QUERY_STRING;
    }
    else
    {
    	$fullurl = $thisurl;
    }
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  8. #8
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does that do, Kevin?
    Echo bad URLs? What do you mean by that?
    But which variables are provided by user or they're all environment vars?

    Thanks
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Basically the above will set $fullurl to the URL that caused the 404 error (rather than the URL that provided the link). We get both and send our administrator an email saying "a link to $fullurl on page $referrerpage caused a 404 error."

    All of the variables are environment vars.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  10. #10
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh nice, where do put it then? In the 404 customized page?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  11. #11
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  12. #12
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am still getting the same problem !

    try http://www.hiphopmusic.co.uk/sdfsdf.html

    Thanks for your help, and it's good to see you back !

    J

  13. #13
    SitePoint Member Victor's Avatar
    Join Date
    Dec 2000
    Location
    Georgia
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using the following code, I too, had problems. Am I missing anything?


    [code]<?php

    $thisurl = $SERVER_NAME . $REDIRECT_URL;
    if ($REDIRECT_QUERY_STRING)
    {
    $fullurl = $thisurl . $REDIRECT_QUERY_STRING;
    }
    else
    {
    $fullurl = $thisurl;
    }

    echo $fullurl . " Unavailable.";
    echo $fullurl . " Unavailable.";


    ?>code]


    The error page only returns the the Domain Name.

  14. #14
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure if you could use $REDIRECT_URL directly but the correct form that I know is

    getenv("REDIRECT_URL");

    And it should return the URL that requested this destination file using redirection (like in .htaccess or config file)
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  15. #15
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want your scripts to be portable you should use getenv( 'VAR_NAME' ); as not all installations of PHP expand the environment variables in actual variables.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  16. #16
    SitePoint Member Victor's Avatar
    Join Date
    Dec 2000
    Location
    Georgia
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still, no luck.

    test here
    http://sprungmind.com/page/exist_not.html

    Code:
    <?php 
    
    $redirecturl = getenv("REQUEST_URI"); 
    $servername = getenv("SERVER_NAME");
    $thisurl = $servername . $redirecturl; 
    $redirectquerystring = getenv("REDIRECT_QUERY_STRING");
    
    if ($redirectquerystring) 
    {
    	$fullurl = $thisurl . $redirectquerystring;
    }
    else
    {
    	$fullurl = $thisurl;
    }
    
    echo $fullurl . " File Doesn't Exist or is Temporarily Unavailable."; 
    
    ?>
    I've tried REQUEST_URI and REDIRECT_URL

  17. #17
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That page is protected, I got 401 since I don't know the password
    And secondly, it's weird when I tried, I got very weird result from getenv("REDIRECT_URL");

    It produces some files that I've NEVER seen!
    Probably there is some issue with share server (probably those are others' file on the same server!)
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  18. #18
    SitePoint Member Victor's Avatar
    Join Date
    Dec 2000
    Location
    Georgia
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It produces some files that I've NEVER seen!
    Probably there is some issue with share server (probably those are others' file on the same server!)
    Can you help me understand? I can't duplicate what you speak of.

    Also, by the way...

    username: support
    password: thankyou

    Your help is graciously appreciated.

    Sincerly,
    <Edited by Victor on 12-20-2000 at 12:51 PM>

  19. #19
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, when I used getenv("REDIRECT_URL");
    I got:

    /grandslam.htm (which is not on my site!)
    and a bunch of other weird things (but I don't have it at the moment)

    So I guessed it could be some files from other sites on the same server, or it could be anything else, I am not sure!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


Bookmarks

Posting Permissions

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