This code would be inserted into the primary web server's 404 error HTML file:
<body onload="missingMP3()">
<script>
function missingMP3()
{
var _loc="";
var _u=document.location.toString(); /* what is the bad URL? */
var _a=_u.indexOf("/previews/") /* does the URL contain this path? */
var _b=_u.indexOf(".mp3"); /* does the URL contain .mp3? */
var _c=_u.length-".mp3".length; /* what is the length of this bad URL */
/*
* If the URL contains the path 'previews' and
* it also ends with '.mp3' then....
*/
if(_a!=-1 && _b==_c)
{
/*
* ...then pick off the missing mp3 file and send the user
* to the other location of the mp3 file.
*/
_loc=_u.substr(0,_a)+"/previews2/"+_u.substr(_a+10,_u.length);
document.location=_loc;
}
}
</script>
|