How to redirect a broken URL to another page.

Opps, I have a broken link on my website!

After checking links to my site by typing: site:frutbunn.tk into Google, I found a broken link at frutbunn.tk/webgl/analyser.html

Well, it cannot stay like that, so what to do?

Unfortunately, I cannot recreate this page, it was used to display the settings for a WebGL program I made, but those settings are now shown on the actual blog post itself instead…

But I can ‘redirect’ this now defunct page to the correct one.

And here is how I did it:

I replace the missing (broken) page on my website with a new one that will try to ‘redirect’ the viewers Browser to the correct page. And in that replacement HTML code, I try three methods to redirect the user:

First I try using the JavaScript function location.replace to relocate the Browser to the correct page. So, if the viewer’s Browser supports JavaScript, then JavaScript will quickly relocate the current page to the correct one.

If they have disabled JavaScript, or their Browser doesn’t support it. I try adding a meta tag to refresh the Browser to the correct page.

And if all else fails, I display a message with a link to the correct page.


 Sorry, I had to move this page, if your Browser is not automagically redirected, click here...

I admit, I should have got it right the first time around, and not need to redirect pages. But I’m finding it hard to get things right the first time, and am very much learning as I go!

Finally, the HTML redirect page in full.

OK, and finally, here is the complete replacement HTML file for my broken link at frutbunn.tk/webgl/analyser.html.


 
  
  
 
 
  Sorry, I had to move this page, if your Browser is not automagically redirected, click here...
 

Leave a Reply

Your email address will not be published. Required fields are marked *