How to Create a Customized Visitor Friendly 404 Error Page

Applied on: Windows (ASP) Hosting Plans

This article is easy to implement and has ready-made ASP scripts to work as customized 404 (page not found) pages

Step 1. Modify your web.config file and add the following lines:

<httpErrors errorMode=”Custom”>

<remove statusCode=”404″ subStatusCode=”-1″ />

<error statusCode=”404″ subStatusCode=”-1″ path=”/404.asp” responseMode=”ExecuteURL” />


Step 2. Create an asp file with the following contents:

<body style=”font-face: Arial; font-size: 14″>

<BLOCKQUOTE style=”margin-left: 90px;”>

<b>Page not found – 404 Error</b><br>


<B>Sorry, the page you requested does not exist.</B>


Please check your requested URL <%=”<b>” & replace(mid(Request.ServerVariables(“QUERY_STRING”), instr(Request.ServerVariables(“QUERY_STRING”),”;”)+1), “:80/”,”/”) & “</b>”%> for proper spelling. <br><br>If you think this message appeared in error, please <a href=”contact_us.asp”>contact us</a>.


Or you may follow these important links


<ul style=”margin-left: 120px;”>

<li><a href=”/”>Home</a></li>

<li><a href=”/company_profile.htm”>Company Profile</a></li>

<li><a href=”/services.htm”>Services</a></li>

<li><a href=”/sitemap.htm”>Site Map</a></li>


<h3 style=”margin-left: 90px;”>Other things to try:</h3>

<BLOCKQUOTE   style=”margin-left: 85px;”>


<li>Search <%=request.servervariables(“HTTP_HOST”)%>:</li><br>

<form action=”” method=”get” target=”_blank”>

<input size=”40″ value=”site:<%=request.servervariables(“HTTP_HOST”)%>”>

<input size=”40″>

<input value=”Google Search”>





Step 3. Save the above file as 404.asp at the root of your domain

Now you have created a customized 404 error setting. The result of any 404 attempt will be as shown below:

Tags: , , , , , , , , , , | Posted under Internet, Using Arvixe | RSS 2.0

11 Comments on How to Create a Customized Visitor Friendly 404 Error Page

  1. That’s superb, just what I’ve been looking for! I’ll have a go at that asap! One question, though. Is it possible to use a redirect page to kind of forward link juice to the home page? Just curious, I’ve got a few incoming links that have got corrupted and misspelt, that I’d like to be able to benefit from. If not, no worries, I’m happy to keep the visitors, instead!

  2. Naveed Ashraf says:

    Do you want that when someone tries to visit unavailable page at your website, he/she redirect to your home page? Then check the change in the web.config file at step one.

    Change following
    Here default.html is the default/home page of your website. In your case there is no need to create 404.asp page. Hope this help.

  3. Thanks Naveed, The 404 error page works perfectly, and is really simple to do, even for me! I still always expect that when something tech-related is described as “easy to implement” that it won’t be!

    I kind of think that when a visitor follows a link to a particular page it can be confusing to be redirected to the home page, so I opted to stick with the error page, but what I’ve done is include in the head a canonical tag so search engines hopefully recognise any links as being for the actual content, rather than the error page itself. Is that correct protocol?

    Thanks so much for this post, I really feel like I learned something today.

    • Naveed Ashraf says:

      Your idea is good. I will add following.

      If your deleted page had proper name (detailed name related to its content, like Cheap_Breast_Reduction_Abroad.html), you can add following ASP code in my provided 404.asp file.

      < % qrystr = Request.ServerVariables("QUERY_STRING") qry = mid(qrystr, instr(qrystr, ".com")+7) qry = replace(replace(replace(replace(replace(replace(qry,"~", " "),","," "),"_"," "),".html",""),".asp",""),".htm","") qry = replace(mid(qry, instrrev(qry, "/")+1), ".pdf"," ") qry = replace(qry, ".", " ") %>

      After adding above, change following line in 404.asp


      This will create premade search query string for search engine. This premade query string will be a defult value to search for via Google.

  4. I’m impressed, I need to say. Really not often do I encounter a blog that’s both educative and entertaining, and let me let you know, you could have hit the nail on the head. Your thought is excellent; the problem is one thing that not enough people are speaking intelligently about. I’m very comfortable that I stumbled throughout this in my search for something relating to this.

  5. Mandi Juliar says:

    Appreciate it for this wondrous post, I am glad I discovered this site on yahoo.

  6. hey there and thank you for your info

  7. Lovely blog. Thanks for nice post.

  8. Jay Boden says:


    I used to use a script very simular to this for a custom error page. I just recently move to a new web host and I find that it is not working anylonger. When I get to my error .asp page Request.ServerVariables(“QUERY_STRING”) is empty. Has any of this changed in later versions of IIS?

    Thanks Jay

  9. Pingback: Marketing Automation

Leave a Reply to diy solar energy Cancel reply

Your email address will not be published. Required fields are marked *