Hi, I'm just checking to see if this is best practice:
I want to 301 redirect pages using the below code on a custom 404 page, so that the code checks to see if its on a specific old URL, and if it is redirect to a new URL.
I'd like to check two things - first of all does the below code look ok?
JScript 404 Page Redirector
var oldURL = new Array();
var newURL = new Array();
var strDomain = "http://www.example.com";
var strRedirect = "/";
var strPath = String(Request.QueryString());
oldURL = '/site/example1';newURL = '/example1';
oldURL = '/site/example2';newURL = '/example2';
oldURL = '/site/example3';newURL = '/example3';
oldURL = '/site/example4';newURL = '/example4';
oldURL = '/site/example5';newURL = '/example5';
for ( var i = 0; i < oldURL.length; i++)
if (strPath.indexOf( oldURL[i] ) != -1 )
strRedirect = newURL[i];
strRedirect = strDomain + strRedirect;
Response.Status = "301 Moved Permanently"
Response.AddHeader ("Location", strRedirect);
And what would be the best way to implement it? Should the code above print out HTML in addition, or can I just embed it on a custom 404 page in the site template?
Many many thanks if you can help, I'll shower you in praise and kudos! :)
[edited by: eelixduppy at 1:41 am (utc) on Feb. 10, 2009]
[edit reason] exemplified [/edit]