PDA

View Full Version : Resolved Javascript URL Redirection ?



Cheng
04-19-2009, 07:37 AM
Hi.

If a script like this one is used for url redirection:


<script type="text/javascript">location.replace('http://domain-name.com/');</script>

Will the search engines pickup on it so that after a while redirection is not necessary anymore?

The script is used because the site has been moved to another server with a new domain name.

Thanks in advance,

jscheuer1
04-19-2009, 10:04 AM
Not due to the script. What should happen though is as the search engines continue to spider the web, sooner or later they will discover the new location for themselves, and list it instead. To facilitate this, it would be best to remove all references (like keywords, title, headings, etc.) to the original document from the page that is redirecting.

Also, it wouldn't hurt to also use a meta tag redirect (for non-javascript browsers). And in case both the meta tag and script fail, have a link on the redirect page:


<a href="http://domain-name.com/">This Page has Moved</a>

However, the best thing to do would be to use a server side redirect. With the later, no other redirect is required, and search engines will find the new page more quickly. Keep the link though, it may add to your ranking or be useful in other ways, while it cannot hurt anything.

Cheng
04-19-2009, 12:33 PM
.......hi John, thanks for your reply.

I tried the meta tag before I applied the script but it didn't work or does this tag works only on browsers with javascript disabled?

Anyway, I'm going to add the tag as well.

A server side redirect is out of the question because it's free webspace and they don't give any support whatsoever that's why I moved to a nice free server as it seems.

Keywords been already removed and now I'll go and remove the title as well.

It's a shame because the site was rating pretty well with the old domain name.

Thanks again for your feedback.......

jscheuer1
04-19-2009, 02:08 PM
Well, Firefox (perhaps others) can optionally disable meta redirects. If a browser will follow meta redirects, it makes no difference if javascript is enabled or not. Using it (meta) is just a partial fall back measure. The link is the ultimate fool proof fall back. However, make sure you are using the meta redirect properly. It should be the first thing in the head section of the page, ex:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="refresh" content="0;URL=http://www.google.com/">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body>

</body>
</html>

A common mistake is to quote the URL. However, since it is a part of the content attribute, only the entire content attribute should be quoted.

Now, as to a server side redirect, are you saying that none is available from the old domain, the new domain, or both? The only place you would need (or could use) support for it would be from the old domain. If they have asp, PHP, or another server side language, or even just enable .htaccess - one of those could be used.