Custom 404 error pages

Discussion in 'H-Sphere Shared Hosting' started by tonto, Sep 2, 2005.

  1. tonto

    tonto Perch

    Has anyone gotton custom error pages (404) to work at all? I am trying to set up a custom 404 page. I have tried every combination for the URL option and have had no success. Can anyone help?

    Jodohost support hasn't been much help at all!!!

    I have tried:


    Nothing works. Any suggestions?
  2. Stephen

    Stephen US Operations Staff Member

  3. tonto

    tonto Perch


    How in the world does this help me out? I have allready tried what it says on this page and "IT DOES NOT WORK!"

    I have an open ticket in which no one has given me an answer other than "look at this page." I would like jodohost to tell me the EXACT string that I should put in that damn little box for the URL method.

    Can you do this? OR if you can't do this then YOU put the correct string in the box. It doesn't seem to work for me.
  4. Stephen

    Stephen US Operations Staff Member

    notice the \page.htm that is because it is pulling from the windows filesystem, not the http style /
  5. tonto

    tonto Perch


    That's not what it says for the URL option. It says to use the / Again please tell me the exact string to use if my custom error page is located at:

    I want to use the URL option.
  6. zonefx

    zonefx Guppy

    I got them woking quiet easily!!

    Just select URL and then in the box marked "Path to Custom Error page" type /404.html (or whatever your page is named) and upload your page to the root of your site
  7. tonto

    tonto Perch

    My custom page is in a sub-directory. Does it have to be in the root?

  8. Stephen

    Stephen US Operations Staff Member


    you don't really have to use the URL method if you are not using ASP as the error message filetype.

    using URL method it is relative to your virtual directory, which needs to be /

    if that doesn't work, I can manualyl check the config and see how it is gettign entered into IIS and correct it, I just would need to know the correct file/url to point.
  9. zonefx

    zonefx Guppy

  10. tonto

    tonto Perch


    I just put the 404_error.htm file into my root and I tried the file method. This doesn't work either. Can you just set it up for me. It is not working for me.



    custom error page:

    I can't get it to work at all.

    Very frustating JodoHost!!!

  11. Stephen

    Stephen US Operations Staff Member

    It is set now, I refreshed and almost missed it, it just has a link down at the bottom that is different mainly. :D But, it is working now.
  12. tonto

    tonto Perch

    Cool. Finally. Thanks Stephen!

  13. tonto

    tonto Perch

    Two questions.

    • How can I change this in the future? I just logged into my CP and it does not show a custom error.
    • Do I have to go through a ticket every time I need to set up a new one or edit this one?
  14. Stephen

    Stephen US Operations Staff Member

    I did this manually, you can submit a ticket in the future, I am not sure why it was not working for you, others are set, it seems to be isolated.
  15. dpyers

    dpyers Guppy

    It would be under "Web Services" for each domain.

    FWIW, I route each error to /error.asp (select the "URL" option)
    IIS attaches a querystring to the url formatted as 999;xxxxxxxx where 999 is the 3 digit error code and xxx is the URI that tossed the error. error.asp examines the query string to determine the error that called it and then does stuff based upon the error.

    The stripped down version of error.asp is here...

    'This script...
    ' 1. Extracts the error code and error page from the query string passed by IIS.
    ' 2. Displays the error message.
    ' 3. Uses AspEmail to email error notification to whomever.
    'You will need to change...
    ' 1. strDomain in "GENERAL VARIABLES"
    ' 2. StrReturnAddress and StrToAddress in "MAIL VARIABLES"
    ' 3. href for the stylesheet in the html area
    ' 4. Any email or html particulars you want
    ' -------------------------------------------------------------------------------
    Dim strDomain
    	strDomain =""
    dim arrErrInfo
    Dim strErrorCode
    Dim strErrorMessage
    Dim strErrorPage
    On Error Resume Next
    arrErrInfo = Split(Request.ServerVariables("QUERY_STRING"),";")
    strErrorCode = Trim(arrErrInfo(0))
    strErrorPage = Trim(arrErrInfo(1))
    Select Case strErrorCode 
    	Case "400"
    		strErrorMessage = "Bad Request - Resubmitting the request may correct the problem."
    	Case "401"
    		strErrorMessage = "Authorization Required"
    	Case "403"
    		strErrorMessage = "Forbidden Resource"
    	Case "404"
    		strErrorMessage = "Page/Resource Not Found"
    	Case "405"
    		strErrorMessage = "Method Not Allowed"
    	Case "500"
    		strErrorMessage = "An Internal Server Error has occurred"
    	Case "501"
    		strErrorMessage = "Method Not Implemented"
    	Case ELSE
    		strErrorMessage = "An Unknown Error Has Occurred"
    End Select
    ' -------------------------------------------------------------------------------
    Dim StrReturnAddress 
    	StrReturnAddress = "[email protected]" & strDomain
    Dim strMailServer 
    	strMailServer = "localhost"
    Dim StrSenderName 
    	StrSenderName = strDomain & " Error Page"
    Dim StrToAddress 
    	StrToAddress = "[email protected]" & strDomain
    Dim strVariable 
    Dim StrBody 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    	<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    	<title><%=strErrorCode%> Error at <%=strDomain%></title>
    	<link rel="stylesheet" type="text/css" href="/site.css">
    	<div align="center">
    		<h3>An Error Has Occurred</h3>
    		<p>Error: <%=strErrorCode%> - <%=strErrorMessage%></p>
    		<p>Requested Page: <%=strErrorPage%></p>
    	<div align="center" style="margin-top:30px;">This error has been logged.</div>
    StrBody = "Error at " & strDomain & vbCRLF
    StrBody = strBody & strErrorCode & " - " & strErrorMessage & vbCRLF
    StrBody = strBody & "Page = " & strErrorPage & vbCRLF
    	Dim objAspEmail
    	Set objAspEmail = Server.CreateObject("Persits.MailSender")
    	objAspEmail.Host = strMailServer
    	objAspEmail.From = StrReturnAddress 
    	objAspEmail.MailFrom = StrReturnAddress
    	objAspEmail.FromName = StrSenderName 
    	objAspEmail.AddAddress StrToAddress 
    	objAspEmail.AddReplyTo StrToAddress 
    	objAspEmail.Subject = strErrorCode & " Error at " & strDomain
    	objAspEmail.Body = StrBody 
    	On Error Resume Next
    	Set objAspEmail = Nothing 
    error.asp is in the root directory. I usually use Instr to check strErrorPage for strings common to bad or moved urls and suggest alternate urls.

    ONE BIG CAVEAT... for some reason, Jodohost doesn't handle favicon.ico as an image error. Firefox tosses a 404 error if it can't find favicon.ico and Jodo handles it as a page error. You'll get to your requested page when the error page starts to be written, but if you email before trying to display the error page, you'll also get an email for the favicon 404.

    I work around it by putting the asp code for mailing after the html code for displaying.

    EDIT: The above error handler will return an error code of "200 - OK". If you want to return the actual error code to the original requestor, add the following line after the "End Select" statement...

    Response.Status = strErrorCode & " " & strErrorMessage

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services