Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Eliminate Error 404

    Let me preface this post with a little story.

    This past February, we went live with a new website. Our old website had been active for many years, but it needed an overhaul. When we had the new site ready to go, I turned the old site off, and our new site on. That was back in February. One of the functions of the new website, was IIS's ODBC logging to an Access 97 .mdb. For the past month or so, I have been slowly but surely adding ASP pages to an Administrative site, to show information about who is hitting our site, when they are hitting it, and what they are seeing. Yesterday, I finally made a page that showed the actual hits to each page on our site. When I ran that page, it showed in the number 6 slot, a link that doesn't exist on our site: /faq.htm. Our current FAQ site is further into the site then just the root folder. This was kind of surprising. In fact, we had over 6000 requests (since February) for that page. When I tried the page, I got the Error 404 Page not found web page.

    Not good. I looked at our old site, and sure enough, in the root was a page called faq.htm. My initial instinct was to put a faq.htm page on our new site, that had a link to the new FAQ page. But then it dawned on me. How many other pages had 'ghost' links on the internet, which would cause potential visitors to give up, when a link is bad?

    So, yesterday I built an Access 97 database, VB 6.0 .dll, and ASP page, which are all attached to this post. I then went into my IIS server settings, and changed the 404 page to my new ASP page.

    The results? Now, when a user hits our site, if the page they are requesting cannot be found, the ASP checks the URL in the database. If it finds a match in the suggested routes, it sends the user a page that gives the explanation from the database, with a link to the new page. That page refreshes after 10 seconds, to the referred page. If there is no match, it uses the 'default' message and link (our home page), which is also in the database (so it can be changed without recompiling the .dll). It also logs the hit (URL, Referrer, IP Address and TimeStamp). That means no matter what page you are trying to find on our site, if it doesn't exist, you get a page that loads our homepage for you!

    No more 'Page not found' errors!

    Hope someone else finds this useful! <img src=/S/sailing.gif border=0 alt=sailing width=25 height=25>
    Attached Files Attached Files

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Cairns, Queensland, Australia
    Posts
    885
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Eliminate Error 404

    I stand in awe! I understand what you say, and mostly what you've but that you actually thought all that through and came up with a working solution <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

    Thanks for sharing this, on behalf of those who can use it. (I outsource all our web work as I just don't have the time.)
    Granville

  3. #3
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Eliminate Error 404

    Actually, you could probably use this if you wanted too. A lot of web hosts that provide IIS servers (which allow ASP pages) do allow for custom ActiveX .dll's. Even if they don't, you can just have the ASP page read the database on it's own. (I just like using VB .dll's, makes life simpler for me most of the time). Then it's just a matter of getting their tech support guys to change the 404 page for you, to your new ASP page.

    Thanks for the comp. This thing just hit me like a ton of bricks, cause I can't imagine why I never thought of it before, it seems so simple! <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Cairns, Queensland, Australia
    Posts
    885
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Eliminate Error 404

    Thanks, Drew.

    I've download the attachment and will take a look.

    My problem lies in our site being hosted by our corporate office. I very much doubt they will allow this, because they aren't very savy. I was a "rebel" as our company was the last to move to their host as they couldn't /wouldn't enable SSL and I had on-line bookings ruuning about 18 months before they decide they could "reduce costs" by being their own host.

    I'll have a play anyway, you never know when things like this will prove useful. Ta.
    Granville

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Eliminate Error 404

    You've got me in the mood to roll up my PHP sleeves and see what I can whup up for non-MS server technology. Drew, can you give me an idea of the DB structure you created? I don't imagine it to be exceptionally complicated...the beauty of code with a single purpose.
    -Mark

  6. #6
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Eliminate Error 404

    Hmmm, the database is attached. There are three tables.

    Table 1. The Log. It has a field to record the requesting URL (which gets the URL, which, from an IIS server, the 'real' requested URL is in the QueryString), then a field for the IP Address, the Referrer (in order to track where the bad links are coming from), and finally a Date/Time stamp.

    Table 2. Special routes. In my case, I have one record so far. It has a URL field, a New URL field, and a memo field. The first URL field is the 'old' URL, the second is the URL the first is supposed to be redirected to. The Memo field is the text displayed to the user.

    Table 3. Default URL field, and Default message Memo field.

    All hits to the page are logged in Table 1. The URL retrieved from the querystring (the URL the user tried to hit) is then queried against the first URL field in Table 2, to see if a custom URL and message is setup to direct to an appropriate page. No match, then it loads the information from Table 3 (which should only have on record (I just did that so that it's dynamic, I can change that record on the fly, without affecting anything else.....)). It then displays a page with the Memo text (either specific, or the default), with a link (either specific, or the default), and a Refresh MetaTag, which goes to the New URL.

    Make sense?

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Eliminate Error 404

    <img src=/S/doh.gif border=0 alt=doh width=15 height=15> I didn't bother to look in your zip before I opened my yap. Thanks Drew.
    -Mark

Posting Permissions

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