[2005] Can I 301 redirect an HTML page?
I have a customer's website that I replaced a specific HTML page (which was a form customers fill out) with an ASP.NET application to make it more robust.
My issue is that search engines still catalog the html page, so some visitors still hit it. I don't want to just take the old page down, because then they might think the site no longer exists if they hit that specific URL via a search engine, so I want to redirect to the ASP.NET app URL.
I know I can do a meta tag refresh to the new URL, but I also know that is generally the least desirable method of doing this. I read the proper way is to issue a 301 redirect header, however I am not sure if I can do that with a standard HTML page, since I don't want to change the page extension to asp because again that screws up the search engine results.
I also unfortunatly have no file/directory level access to IIS for this site, so any IIS setting for redirect is also a no go.
Are there any other options, or is the Meta tag refresh pretty much my only one?
Re: [2005] Can I 301 redirect an HTML page?
don't know much about meta tag refreshing, but I always have just used javascript to execute a forms .submit() function to auto-redirect a page.
so I would add a form like so...
html Code:
<form id = "redirect" action = "http://www.newurl.com/blah/blah">
</form>
and then onload just execute the following function
js Code:
function autoRedirect()
{
document.getElementById('redirect').submit;
}
is this an ok method or no?
Justin Fox
Re: [2005] Can I 301 redirect an HTML page?
it basically has the same effect as the meta tag refresh.
The reason I want to do the HTTP 301 redirect is that it doesn't cause an extra history write, so for example:
user clicks link in search engine, brings them to old page, old page auto redirects to new page, user clicks back button on new page, is brought back to old page, which redirects to new page again, infinite loop...
I am sure you have noticed this when clicking back on a certain page it keeps pushing you forward again. You have to slam on the back button a few times quickly to get back where it won't forward you. It is just more professional if you can do it without this issue.
Re: [2005] Can I 301 redirect an HTML page?
Ah ok, did think about that'n....
Hmm...
That's crazy stuff. I don't know how you'd make it to where when they hit the back button it doesn't foward them again.
Maybe you can make a cookie and write a boolean text to it and then use the eval() function in js to tell whether they've been there already or not, if so don't do the .submit.
That seems kina long and drawn out though..
Justin Fox
Re: [2005] Can I 301 redirect an HTML page?
I found this on google, maybe it can help...
asp Code:
<%
Response.Status = "301 Moved Permanently"
Response.addheader "Location", "http://www.yourdomain.com/newpageurl/"
Response.End
%>
Justin
Re: [2005] Can I 301 redirect an HTML page?
Thanks for your efforts, but I also searched the web prior to posting my question.
Since the current page is just a regular html page with a .html extension, I can't run ASP code in it. I would need to change the extension to .asp, and that would break the search engine issue that I am dealing with in the first place.
So basically I needed to know of any way to do this without server side scriping.
Re: [2005] Can I 301 redirect an HTML page?
that stinks... you can't make it to where the server will parse .html files too?
kinda like embedding php script in a .html file?
trying to learn too lol,
Justin Fox
Re: [2005] Can I 301 redirect an HTML page?
There are all kinds of things you CAN do, if you have access directly to the server the site is hosted on. In fact if I had direct access to the IIS server, I could just add a 301 right in there and the redirect would happen automatically when the old page was requested. This site is hosted by a 3rd party webhost, so I have little more than FTP access to upload the site files. I can't make any IIS changes.
Re: [2005] Can I 301 redirect an HTML page?
Oh. Well I'll be watching for the solution :)
Justin Fox
Re: [2005] Can I 301 redirect an HTML page?
I am beginning to think there is not one for my specific scenario, and I will need to use the meta tag refresh to do this.
Re: [2005] Can I 301 redirect an HTML page?
Re: [2005] Can I 301 redirect an HTML page?
I think another benefit of using true 301 redirects, is that some (if not all) major search engines will actually update their databases to know that the given link is permanently redirected to the new page. Instead of continuing to simply index the old and new pages.
Re: [2005] Can I 301 redirect an HTML page?
If you cannot access IIS, then you cannot create an HttpHandler to handle the .html and perform the 301. Your next best bet is to ask your web hosts to map the .html and .htm extension to the ASP.NET ISAPI DLL and handle the request in your global.asax file. If they refuse to do that (which they will), then check to see if it's dual hosted (apache + IIS), in which case you can use an .htaccess file.
If you can't do that either, then either place a simple link on the page so that the crawlers pick it up or use the meta refresh, but the meta refresh really isn't a good idea. The fact that the page has been found means that the search engine sees a 200. A refresh after that is irrelevant. Might as well just place a link there.
Re: [2005] Can I 301 redirect an HTML page?
can you explain a bit more about the dual hosting scenario? Do you mean apache that is running IIS (which I have not ever seen AFAIK) or you mean the site is actually hosted on 2 seperate servers?
It is in fact though, JUST a windows server, the particular host is an MS gold partner and doesn't even offer linux/unix hosting packages.
Re: [2005] Can I 301 redirect an HTML page?
Some hosts give you both IIS and Apache on the same server, I am currently hosted with one of those. The .html, .htm, .jpg, .gif, .php, .cgi etc requests go via Apache and the .asax and .aspx requests go via IIS. This allows you to play around with .htaccess to give you a certain level of configurability and control when IIS access is not available.
You don't have it, so you're stuck with the last option.
Re: [2005] Can I 301 redirect an HTML page?
It is sort of strange you can't add an HTML directive to act like a 301. Oh well. Right now I am using the refresh meta tag. I know its not a good option, it just happens to be my only one for the given scenario.
It is shared hosting, so I am sure they are not going to bend over backwards to change IIS settings for me.