• Eliminate Error 404

    Author
    Topic
    #388557

    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! sailing

    Viewing 0 reply threads
    Author
    Replies
    • #682708

      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 clapping bow

      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.)

      • #682714

        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! scratch

        • #682717

          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.

        • #682761

          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.

          • #682788

            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?

            • #682814

              doh I didn’t bother to look in your zip before I opened my yap. Thanks Drew.

    Viewing 0 reply threads
    Reply To: Eliminate Error 404

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: