You have been redirected to CoverYourASP.com - find out why and how! | ||
Pepper Spray & Stun Gun Specials! KEEP THEM SAFE. | ||
CoverYourASP --> How I moved to CoverYourASP |
| As I've mentioned here, by the end of August 2000 the time had come to move my ASP examples from my personal home page at ShawThing.com to this new domain - CoverYourASP.com. This article describes the simple measures I took to ensure that people were seamlessly redirected, and even welcomed on the new site! The first decision I made was to use my 404 handler to trap the pages that had been moved. I could have replaced the moved files with ones containing a redirect, but I decided not to - I hate duplicate code. If I had made a mistake in the redirect code I would have to change it again in each file. So instead I set up my 404 handler to redirect. The code I used is shown below:
The first problem I found with this is that people were linking straight to the ShowSource.asp page - this uses the QueryString to name the page to display. A typical URL would be ShowSource.asp?page=Categories. The 404 handler unfortunately stripped off the QueryString when it failed to find the file, so the user got redirected to ShowSource.asp - without the "page=Categories". The solution was to leave a simple ShowSource.asp on my old site. This was the only page that used QueryStrings so I wasn't going against my "no duplicate code" principle. The file is shown below:
So, that's the redirects taken care of - everyone who visits an old page on ShawThing.com will end up at CoverYourASP.com. Now look again at the code above. Can you see the extra FromShawThing parameter I added to the URL? This is how I implemented the "welcome" text that appears at the top of the pages. If you want to see it, reload the page. As you'll see below, I can even tell that you clicked on that link above! The welcome text was added to the Header () function you should all be familiar with. If not, you should read my article about how I use SSI first. The new code is shown below:
You can see how I set a global variable "bRefered" if there is a "FromShawThing" in the QueryString. This variable can be used in the main page content if necessary. Incidentally, I could have checked for ShawThing in the Request.ServerVariables ( "HTTP_REFERER" ), but that's a more "expensive" call, and I couldn't then have demonstrated it above!
|
|