Have you ever been into a situation where you had built static pages and later you wanted to either move that page to other location or convert it into dynamic pages using .Net/php/jsp? If your server would be Linux, you would use .htaccess file to redirect it but for IIS it would be a headache. I had been in that situation where I was converting a single static page of page rank 4 to be a dynamic page. Along with convenience of visitors, I was thinking about page rank because it would take more time to achieve the same page rank with new page without redirection. If this page would be dynamic, I would have done it very easily but how do you issue 301 redirect to the browser for a static page? Well, the solution is very simple.
I have created custom404.aspx (or custom404.php/custom404.jsp) file and within IIS, I have assigned this file to be executed when 404 error occurs. Many hosting providers gives this kind of functionality so even if you are using 3rd party web hosting, you would most likely get this facility. If not, you may request your hosting provider and they would be able to do it for you.
Here is a pseudo code in custom404.aspx file
If Requested URL = "StaticFileName.htm" Response Status Code = 301 Response Location = "New URL.aspx" Else Response Status Code = 404 Response Body = "<h1>File not found></h1><p>Requested file not found</p>" End If
Of course, this trick requires you to delete the static page from your Web server.
Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1’s and 0’s from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.