404 error and cgi variables

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 404 error and cgi variables

    Hello all,
    We have a custom 404 error page that our provider has set the link to through
    the IIS.
    We have set the page email us using cfmail when the page is hit.
    In the email we are using cgi variables to get the informaton needed.

    My question is: Is there a way to grab the information of the page they were
    trying to get to? I can see where they came from but that does not tell me what
    page may be possibly having a problem.

    Thanks for your help in advance.
    jmoshier

    <cfmail to="webmaster@domain.com"
    from="webmaster@domain.com" subject="ERI - 404 Error Occured" type="html">
    A user has encounted a 404 error. Details about the error are listed below:
    <br><br>
    <strong>Page User Coming From:</strong> #cgi.HTTP_REFERER#<br>
    <strong>HTTP User Agent:</strong> #cgi.HTTP_USER_AGENT#<br>
    <strong>Remote Address:</strong> #cgi.REMOTE_ADDR#<br>
    </cfmail>

    jmoshier Guest

  2. Similar Questions and Discussions

    1. Client Variables Error
      Can someone advise action to take for: "Operation failed on the data source named "CliVars". Reason of failure "Invalid precision value " We are...
    2. [PHP] URL variables parsing error?
      Hi, hiaer@azrael.sk wrote: Try this: <?php echo "var1: {$_GET}"; echo "var2: {$_GET}";
    3. URL variables parsing error?
      Hi all, I use RedHat9.0 with Apache 2.0.40 & PHP 4.2.2 and I have problem with parsing URL variables... I use this URL:...
    4. A bug with class variables and using it as an error handler?
      Paul Liversidge wrote: You should declare your variables in the class, but only initialise them in the constructor. This was a change in PHP4....
    5. Session Variables Error
      I am trying to use Session Variables but am receiving the following error. System.Web.HttpException: Session state can only be used when...
  3. #2

    Default Re: 404 error and cgi variables

    As an aside, make sure you are not emailing for EVERY 404 error--missing images will also trigger this script. In a year from now when your site goes through a redesign, you will regret it. :-)


    sdwebguy99 Guest

  4. #3

    Default Re: 404 error and cgi variables

    cgi.SCRIPT_NAME contains the page they were requesting.
    cgi.QUERY_STRING contains any url parameters.
    (Standard and Apache syntax -- may be different on IIS)

    Cheers,
    -- MikeR
    MikerRoo Guest

  5. #4

    Default Re: 404 error and cgi variables

    MikeR,
    I tried to use the script name variable and all it gives me is the name of my
    404 page. Not the actual URL they were trying to get to.

    Could this be because it is IIS?

    Thanks for the help
    jmoshier

    jmoshier Guest

  6. #5

    Default Re: 404 error and cgi variables

    Yes. IIS must be doing some kind of internal redirect.
    IIS may set a non-standard variable that has the information you need.
    Put <CFDUMP var="#cgi#"> in your code and you might get lucky and see
    something.

    Barring that: use CF, not IIS, for 404 errors on CF files.
    In CF administrator, check "Enable HTTP status codes".
    Then specify your 404 handling template in the "Missing Template Handler".
    CGI.Script_Name DOES work properly in a file triggered this way.

    Good luck,
    -- MikeR

    MikerRoo Guest

  7. #6

    Default Re: 404 error and cgi variables

    Mike,
    Thanks for the information. Unfortunately we can't specify a Missing Template
    in the CF admininstrator. We are on a shared server.

    Do you possibly know of another way to get the URL the user was trying to
    reach?

    Thanks,
    jmoshier

    jmoshier Guest

  8. #7

    Default Re: 404 error and cgi variables

    Sounds like the real problem here is your provider. Maybe it's time to
    pressure them or to switch?

    Anyway, i can only think of one other way to get this info. That's to have
    your template open and parse the log files. Your provider has probably
    blocked this method too. And, anyway, I don't recommend it.


    MikerRoo Guest

  9. #8

    Default Re: 404 error and cgi variables

    Just thought of another method that may or may not work...

    Create an Application.cfm or Application.cfc file that sits at the root of
    your web folder -- or add the add the following capability to all existing
    Application.cxx files:

    The CGI variables work correctly in the Application.cxx files. Copy each
    request into a session variable. Hopefully, when your existing 404 page is
    triggered, the session variable will be available and you can see the last
    requested page.

    Good luck,
    -- MikeR


    MikerRoo Guest

  10. #9

    Default 404 error and cgi variables

    For Apache/Linux:

    Apply something like my code below on the handler page:

    <cfset the404 = cgi.REDIRECT_URL>

    <cfif the404 CONTAINS ".php">
    <cfset theFileName = listLen(the404,'/')>
    <cfset theFileName = listGetAt(the404,theFileName,'/')>
    <cflocation addtoken="no" url="/some_directory/#replaceNoCase(theFileName,'.php','.cfm')#">
    </cfif>
    Unregistered Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139