The Internet Marketing Driver: Glenn Gabe's goal is to help marketers build powerful and measurable web marketing strategies.

Tuesday, January 08, 2008

301 Redirect HTML Files Without Using ISAPI Rewrite

Using 301 Redirects When All Else FailsWhen you run a website, there are times that you'll need to redirect older webpages to newer webpages or you might want to redirect multiple domain names to a single domain name. There are two key ways to accomplish this task, issuing a 301 redirect or a 302 redirect. What you might not know is that a 301 redirect is search engine friendly and a 302 redirect is not. 301’s will safely tell the search engines that one page has been permanently moved to a new location, while 302’s tell the search engines that it’s a temporary redirect (which can cause problems down the line.) This shouldn’t be news for anyone working in the search industry, but might be news for website owners outside of the industry. My post today isn’t about what 301’s and 302’s are, but it’s about a unique challenge I ran into recently with one of my clients. We needed to 301 redirect several HTML files to new pages on the website without using the standard methods of issuing a 301 redirect. Also, the website was running on a shared server, which was an added barrier. By writing this post, my hope is that I can help some of you who might run into the same situation. More on this soon. Let’s start with a quick review of redirects.

Let’s Define 301 and 302 redirects:
A 301 redirect is a permanent redirect and tells the search engines that the old webpage has been permanently moved to a new location. It basically tells Google and the other engines that you have permanently moved one page from HERE to THERE. If you need to redirect a file on your website, then you should always use a 301 redirect.

A 302 redirect is a temporary redirect, and is not search engine friendly. It basically tells Google and the other engines that the file in question has temporarily moved from HERE to THERE. There have been vulnerabilities in the past with using 302 redirects, which is a reason that 302’s aren’t trusted. If you need to redirect one page to another on your website, then don’t use a 302. Always use a 301 redirect when possible.

The 301 Challenge
Back to the redirect challenge that I recently faced. Again, my hope is that the solution can help some of you who might run into the same situation. One of my clients has a website that’s running on a windows server and contains a combination of HTML, ASP, and files. We needed to redirect several older HTML pages to new pages, which at first glance would be relatively simple to do. If you are on a windows server, I highly recommend using ISAPI rewrite to issue 301 redirects. This is similar to using an .htaccess file on a linux or unix server. You can issue one line commands using a text file named httpd.ini that sits at the root level of your website. It easily enables you to issue 301 redirects, rewrite URLs, etc. It’s a great utility to have installed…

The Shared Server Problem
Here was the problem. We couldn’t use ISAPI rewrite. The website was running on a shared server and the web hosting company would not install ISAPI rewrite on the server. Some hosting companies will and others won’t…this specific hosting provider wouldn’t after several requests to do so.

Issue the 301 Via Code
So, my next move was to issue the 301 redirects via code (either through ASP or There was also a problem with using this technique. The files we needed to redirect were HTML files and not ASP or files, so I couldn’t add the necessary VB or VBScript code to the pages that needed to be redirected. Moving on…

Run HTML Files Through
My third idea was to run all HTML files on the website through, which would enable me to add code to each of the HTML files. Basically, when an HTML file is requested, it would run through the engine. Then I could issue the 301 redirect via code instead of using ISAPI rewrite. Cool, right? The hosting provider made the change on the server (running HTML files through, but to our dismay, some of the HTML files on the site were not rendering properly. So, we reverted back to the original setup (where HTML files were not run through Again, moving on…

The Fourth Time is a Charm…
My fourth idea finally worked. The hosting provider basically said we were out of luck, but I wasn’t ready to give up so fast… I knew that Classic ASP is still supported on windows server, even when running Classic ASP was the original version of Microsoft’s server side scripting framework. The next version of the framework was, which has also gone through its own upgrades over the years. So, I posed the question…couldn’t we try and run HTML files through Classic ASP instead of My client’s hosting provider made the change and bingo, it worked like a charm. We can now issue search engine friendly 301 redirects on HTML pages. Just to clarify, this meant that I could add Classic ASP code to any HTML file running on the website. For our purposes, I could issue a 301 redirect via Classic ASP code, the HTML file would be run through the Classic ASP engine, and everyone would be happy. :)

The Added Benefits of Using This Solution:
The obvious benefit is that we can now use 301 redirects with any HTML file on the website, when needed. The added benefit is that we can now also use Classic ASP code within any HTML file running on the website. Typically, HTML files can only contain HTML code (no server side functionality.) But with this solution, I can make database calls, provide dynamic content, use session variables, and any other Classic ASP functionality available. It’s a flexible solution, to say the least.

In closing, please remember the following items when you need to redirect HTML files on your website:

1. If you need to redirect a webpage or domain name, use a 301 redirect.

2. Don’t use 302 redirects. If you do, use them at your own peril. {cue mad scientist laughter}.

3. If your website is hosted on a windows server, use ISAPI rewrite to issue your 301 redirects. It's a great utility.

4. If you can’t use ISAPI rewrite and you are in a shared environment, try and issue the redirect via ASP or code. If you are trying to redirect HTML files, you’ll need to skip to #5 below.

5. If you can’t add or Classic ASP code because you are working with HTML files, then try running your HTML files through the or Classic ASP engine. Then you’ll be able to add the 301 redirect code to your HTML files.

Happy Redirecting!


Labels: , , , ,

If you enjoyed this post and you need assistance
with your online marketing projects,
then contact Glenn Gabe today>


  • At 2:38 AM, Anonymous said…

    The above article is a good one, but still it missed out purpose of explaining how to do the redirect. I mean the explanation is lacking for

    5. If you can’t add or Classic ASP code because you are working with HTML files, then "try running your HTML files through the or Classic ASP engine". Then you’ll be able to add the 301 redirect code to your HTML files.

    My doubts are inside quotes. I am not an expert in asp so might be that’s why I wasn't able to understand.

  • At 2:52 PM, Blogger Glenn Gabe said…

    Thanks for your comment. I definitely plan on writing a post for how to use isapi rewrite and I hope to get to it soon. It's extremely important on several levels, especially for SEO purposes...

    Regarding running html files through asp classic or, that's something you can set at the server level. Ask your web hosting company to do this for you. They will know exactly what to do. If you want to do it yourself (if you are running your own website), then you can edit your configuration in IIS at the website level or down to the virtual directory. You can select file types and run them through the dll of your choice (like asp.dll or aspnet_isapi.dll.) I'm assuming you are using iis.

    I hope this helps and check back often for more posts on isapi rewrite.



  • At 2:35 PM, Anonymous Paul R said…

    For me No. 5 is absolutely in affect, however.. I have absolutely no clue what / or how to do this!
    I have a lot of html files that have to be 301'ed to asp files, shared hosting (GoDaddy)...
    Hopefully you could explain this part a little more (for the non-scripting-guru's as well?)

  • At 8:39 AM, Blogger Glenn Gabe said…

    Hi Paul. If you don't have control over the server you are on (shared hosting), then contact GoDaddy and ask them to install isapi rewrite. Actually, it may be installed already. If it is, then you can use it to redirect any of your html files to asp files.

    If they won't install isapi rewrite, then ask them to run your html files through classic asp or Then, you can add asp code to your html files and force the 301 (like I explained in my post). If they won't do that, then change hosting providers. :)


  • At 1:57 PM, Anonymous Anonymous said…

    Hi Glenn, your article is very informative, but I have a little different situation. I have a bunch of html files on IIS as well as on Apache servers. I have a ASP.NET web application that performs authentication to access these html files. So when an html file is accessed on these servers, I need to redirect to my web application to do authentication and if successful, I need to open the help file. Please help me with this.

  • At 9:06 AM, Blogger Glenn Gabe said…

    It sounds like you have an interesting setup. Here's the problem from an SEO standpoint. If you are hiding these pages behind a login, then they can't be indexed. Therefore using 301 redirects still won't let you pass any search power from your old pages to your new pages.

    However, if you are just looking for the best way to force authentication, then that's an easy task in asp or Simply set a session variable that can be checked on each page on your site and then redirect to your login if it's not set. In order to add asp code to your html files, run all html files through (the dll). Your hosting provider can easily set that up for you and then you'll be able to code away on your html pages.

    I hope that helps.


  • At 2:51 PM, Anonymous Ilene said…

    So far your post is the closest to the answer I'm looking for...
    My html files are on a windows server. I'm told by the hosting company that I need to do a 301 redirect from "http:" to "https:" to show the new secure cert.
    I'm also told by the hosting company that it is "code" that needs to be put in my html page. Makes no sense to me, but I've searched for the last 6 hours and have found nothing!
    Any help would be appreciated to steer me in the right direction.

  • At 3:12 PM, Blogger Glenn Gabe said…

    Hi Ilene. Ask your hosting company if you can use ISAPI Rewrite (if it's installed on your server). If not, ask them to install it. :) It's a great way to handle 301 redirects on a windows server.

    If they won't install it, you can write ASP or code to handle 301's, but that would require that your pages are .asp or .aspx files. If your pages are html files (.htm or .html), then you could use the technique listed in my post above. Your hosting company would have to run all html files throuh ASP for your website. Then you can add the necessary code to 301 your files.

    I hope that helps.


  • At 4:29 PM, Anonymous Ilene said…

    Will certainly give it a try. It's you know offhand if they will do this? Honestly, I spent HOURS on the phone with them today and got nowhere with them. They just kept telling me to do a Google search for 301 redirects and that they can't help me.
    Very frustrating...but I'll try anything at this point.
    Thanks so much for your speedy response. Much appreciated.

  • At 11:52 PM, Anonymous Anonymous said…

    Hi Glenn, your article is very informative, but I have a little different situation. I have a bunch of html files on shared hosting windows server. So when an html file is accessed on these servers, I need to redirect to my html pages with www. Means if i enter any page without www, it should redirect to with www. Please help me how to redirect HTML pages through ASP and how to insert Classic ASP code into HTML Pages and what code i have to insert. please help me on this

  • At 8:07PM Anonymous AL said…

    I'm using Windows/Shared Hosting/GoDaddy and recently moved all .html files to .aspx files. I setup my site to use my custom 404.aspx page and put my 301 redirects in the 404 page itself.
    When a visitor gets the 404 page, the asp code checks to see if the requested url is a page that I know I have moved. If so, I use this code to redirect:

    <%@ Language=VBScript %>

    IF reqURL = "known_url.html" THEN
    Response.Status="301 Moved Permanently"
    Response.AddHeader("Location", ""
    Response.Status="404 Not Found"
    END IF

    The visitor will either get a redirect, or a 404, all done in one script.


Post a Comment

Links to this post:

Create a Link

<< Home