404 Trick for Web Promotion

Here is a way to turn a Web surfer’s mistyped URL into a possible purchase. By changing the nasty 404 Not Found error page into a custom page that helps them find what they need, you earn accolades from your visitors, instead of a hasty exit. You also help the search engines keep you properly indexed. Burhan Khan explains how it’s done.

In this article I show how to get a static looking page name for a dynamic page, how this is useful for search engine ranking, and how to create a custom 404 error page. When using this technique, you don’t need any software to rewrite URLs. I use an IIS example.

Why do you need a 404 custom page? Well, what happens when someone requests a page on your site that does not exist? Have you ever noticed that some sites give you a very nice looking page when you mistype a URL, instead of that nasty 404 File Not Found? It is easy to create a 404 custom page in IIS and Apache.

Then again, there’s the search engine’s point of view. It is the biggest benefit to have well named pages. Most search engines, like Alta Vista and Yahoo, do not traverse pages with question marks (?) in them. Traversing such pages could cause them to enter into an infinite loop.  By converting your dynamic looking URL to a static page, every search engine will index your site. Once your website is indexed, your next job will be your website optimization (Meta tags, optimized code, etc.).

Dynamically generated pages are the only way to have a truly big site, with only few pages. However dynamic pages names are not user friendly. It is difficult for users to remember the URLs of dynamic pages. For example, www.mysite.com/product.asp?id=23 is not memorable as www.mysite.com/java_book.htm.
{mospagebreak title=Setting up IIS for custom errors}

In order to get a static looking page name, you need to customize IIS. I recommend that you use IIS 5, because it uses two great objects (Server.Execute and Server.Transfer) in your Active Server Page. IIS 4 uses Response.Redirect, which is not suitable for this purpose, because search engines can see that the page is redirecting. Also, it opposes the rules of SE. Using redirection can even cause search engines to ban a website, which means that they will not index any page coming from that website.

Now you need to tell IIS that you want an Active Server Page (404.asp) to handle all the 404s that come to the site. First open Internet Service Manager and right click on the website for which you want to set the custom 404 error. Click on properties and choose the Custom Error tab. Now you will see a list of HTTP errors. Click on the 404 HTTP error and you will see the filename that is already associated with this error. All you need to do is edit this file directory by choosing Edit Properties. Now you can tell the URL about the custom 404 error (404.asp) file.

After you make this change, all 404 errors will be handled by 404.asp. An interesting thing about IIS is that it sends the page name that caused the error as parameters in the querystring.

Creating the database

Now let’s consider a website which shows 100 products. We design one page (product.asp) to handle these 100 products. Now we only pass product id to that page and, corresponding to that product id, we fetch records of that product. The URLs look something like this:


Surely those product ids are stored in the database along with other fields such as product name, price etc. We need to add one more field, say PageName. The PageName field will contain a suitable file name for that product. Remember, this file will not physically exist. Just like this:

1Moviemaker for P800$200 …….Moviemaker-for-p800.htm
DVD to Pocket PC$100 …….DVD-to-pocket-PC.htm
3Samsung C100$150 …….Samsung-C100.htm

Using the database for that purpose is easy to handle and easy to remember. We fix the desired static looking pages in the database. These file names should follow the product name and, if possible, should contain keywords.

{mospagebreak title=Linking}

What do you do to switch from one product to another product? Certainly, we create a link and get the product id from the database and place it in querystring. Such as:

<a href=”product.asp?id=<%=ID%>”><%=Product_name%></a>

But now you should change it. Instead of passing the product id with querystring, you need to get the corresponding PageName and redirect to that page. Such as:

<a href=”<%=PageName%>”><%=Product_name%></a>

It will now redirect to:


At this stage we get a static looking URL. That page does not really exist, but we code it in 404.asp to handle it and execute the original page.

Creation of the 404.asp page

Now we need to create the 404.asp page to handle all 404 page not found errors. For this purpose we need to get the name of the page that had the 404 errors. As I already say, IIS sends the name of that file with querystring. So we need to get querystring.

‘ Getting page name
dim PageName
PageName = Request.ServerVariables(“QUERY_STRING”)

Here we get the page, such as DVD-to-pocket-PC.htm, in the PageName variable. Now we have to search the database for this page, and get the product id corresponding that page. It can be done as:

‘ Product id
dim ProductID
set obj = Server.CreateObject(“ADODB.RecordSet”)
obj.Open “select ID from TABLE_NAME where PageName = ‘”&PageName&”‘ “, DBCon

if not obj.EOF then
ProductID = obj.Fields(“ID”)
End if

We simply get the ID and store it in ProductID. If that page does not exist in our database, it means it is really a 404 error. So we need to inform the user that this page does not exist; please try other pages. If possible, give a search box so that the user can search for the desired product from your website.

{mospagebreak title=A Well-Designed Error Page}

When someone gets the generic error message, they will go away and never come back. You will lose visitors and potential customers. It will appear to them that you are not in business.

A well-designed custom error page encourages surfers to remain at your site. Although it’s possible to redirect error codes straight to your home page or site map, that doesn’t tell visitors what’s going on. It’s more user-friendly to explain that there was a problem, and then provide some alternatives. Supply a link to your home page or site map, or offer your site’s search function if you have one. Redirecting to your home page automatically after showing the error message is also a good idea.

Also it is reasonable for you to record some attributes for error detection and correction purposes, such as the following:

  • Date and time of visit.
  • Visitor’s IP number.
  • The exact URL “attempted.”
  • Visitor’s browser Info.
  • The referral (Bad Link Used).

Redirecting to the original page

Now the final thing to do is to execute the original page. For this purpose two useful objects (server.transfer and server.execute) are available with IIS 5. We can use any of these objects, but first let me  tell you which one is efficient.

One bad thing with server.transfer is that we cannot pass querystring. This is a restriction from IIS. So we need to use session object. Just like this:

Session(“Id”) = ProductID

However, if your website seen by 10,000 users per day, then 10,000 session objects are created. It wastes bandwidth and slows down server performance.

The next option is server.execute, and I recommend that you use it. By using server.execute, the URL will not change.

transferURL = “/product.asp?id=” + CStr(ProductID)

Now if you type www.mysite.com/DVD-to-pocket-PC.htm into the browser, you will see the same page as the one that is executed by www.mysite.com/product.asp?1d=2.

One interesting point with this phenomenon is that if we use some directory in the URL, it will not affect things and the page will still execute perfectly. Such as:

  1. www.mysite.com/DVD-to-pocket-PC.htm
  2. www.mysite.com/DVD-products/version-1.2/DVD-to-pocket-PC.htm

These two URLs execute the same page.


Creation of URLs that are search engine friendly in easy with 404 trick. In most search engines static URLs can get ranking instead of dynamic once. And if these static URLs contain keywords, it is more beneficial. Chosen of suitable and powerful page names is still important in order to get visitor on your website.

[gp-comments width="770" linklove="off" ]