SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rewritting a 404 and getting the HTTP_REFERER

    hello

    ekk bizare new design, it reminds me of some airline company, not sure which one or why!!!

    anyway, very annoying thing on my host, they won't let me use my own 404 pages instead i have to use their defined 404.shtml page, anyway need control of my 404 so i've had to write an internal redirect for it like so...


    # turn the rewrite engine on
    RewriteEngine On

    # redirect the 404.shtml to my 404
    RewriteRule 404.shtml projected/1/404.php?queryurl=%{HTTP_REFERER} [L]


    but on the 404 itself i need to get the original page that was demanded by the user and thought i could get it via the HTTP_REFERER passed as a variable, now the synax is correct i think cos it works with HTTP_HOST but no joy with HTTP_REFERER??? any ideas on how i can do this?

    a+
    gar

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi gar :-),

    the only solutions I found are:

    Code:
    # turn the rewrite engine on 
    RewriteEngine On 
     
    # redirect the 404.shtml to my 404 
    RewriteRule 404\.shtml$ projected/1/404.php [L]
    then inside 404.php use the variable $_SERVER[ 'REQUEST_URI' ].

    or another solution is:
    .htaccess
    Code:
    <FilesMatch "404\.shtml">
    SetHandler application/x-httpd-php
    </FilesMatch>
    so 404.shtml can be used as a php file,
    so you can use some variables such as $_SERVER[ 'REDIRECT_URL' ].
    This article is nice:
    http://www.onlamp.com/lpt/a/3158
    and this link is usefull too:
    http://httpd.apache.org/docs/custom-error.html


    :-) pippo
    Last edited by pippo; Feb 27, 2003 at 13:45.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pippo
    or another solution is:
    .htaccess
    Code:
    <FilesMatch "404\.shtml">
    SetHandler application/x-httpd-php
    </FilesMatch>
    hey pippo!

    sorry i was so slow to get back to this, my script changed a bit and through what i did another way i came up with $_SERVER[ 'REQUEST_URI' ] and something similar to your first solution! anyway just wanted to say the second solution you proposed (above) is quite good, might actually use it yet because it eliminates the phantom script 404.shtml that exists in the first solution and well is tidier!!

    <- is it just me or does this smilie seems quite psychotic? the smilies don't seem to work anymore (the click insert), well thats on ie5 on the mac.

    a+
    gar


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
  •