Results 1 to 4 of 4

Thread: Javascript URL Redirection ?

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Javascript URL Redirection ?

    Hi.

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

    Code:
    <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,
    Last edited by Cheng; 04-23-2009 at 02:51 AM.
    Cheng

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    HTML Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Cheng (04-23-2009)

  4. #3
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......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.......
    Cheng

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <!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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •