Script for page redirect

Discussion in 'JavaScript and AJAX' started by bluent, Nov 23, 2005.

  1. bluent

    bluent New Member

    Nov 22, 2005
    Likes Received:
    Trophy Points:
    Home Page:
    Hi Guys

    Before a month I got a script for page redirection from somewhere in the forums.

    var pAddy = self.location.href;
    var pHost = self.location.hostname;
    var pPath = self.location.pathname;
    var nuLoc = 'http:/' + '/www.' + pHost + pPath;
    if(pHost.indexOf('www.') == -1) self.location.replace(nuLoc);

    save this file on server name it, suppose abc.js

    Then call this .js page to home page of your website
    <SCRIPT language="JavaScript" src="abc.js"> </SCRIPT>

    It really works.

    Now I would like to know, does it effect my website in one or other way. If anybody knows about this script and its cons please reply this post.
  2. shabbir

    shabbir Administrator Staff Member

    Jul 12, 2004
    Likes Received:
    Trophy Points:
    First of all I would like to make a note that you have posted this in the wrong forum and I have moved it to the correct forum.

    Now about your query the redirect that you are doing is a JavaScript errors and it has its advantages and disadvantages. The disadvantages are the search engine bots dont read the javascript and so they will not be redirected to the destination page and they will be getting page as blank and so may consider your site as not a site of good content. So its always good to show the same thing to the user as well as to the SE bots. NBow if there is any specific requirements like detect the user country and redirecting him then thats fine Script.

    Also if you are looking for a redirect then I would suggest go for permanent redirect as that helps in gaining Page Rank as well as backlinks to a page.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice