1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

redirect URL in iFrame

Discussion in 'PHP & Perl' started by wayne1, Aug 4, 2009.

  1. wayne1

    wayne1 Newbie

    Joined:
    Jul 13, 2009
    Messages:
    4
    Likes Received:
    0
    Hi

    We have a new domain for our website. The Problem is, that the old domain is not ours and we can't access them.

    The old domain directs to a startpage on a server who's also not ours and in this startpage, the owner of this domain has implemented a iFrame where shows the content of our website. Now it looks, as our website is his website, because all contents are shown over his domain!

    What we want is, that all users comming over the old domain and this iFrame on his server would redirected to our new domain directly!

    Is that possible on any way? Because all redirects in the .htaccess on our server doesn't work :( The users where redirectet, but they see in the URL address bar always the old domain and not our new one.

    I think a code where say "everything is comming from domain.old.com, if iFrame or what else, would be forwarded to our domain.new.com and our domain will also showed on the users address bar".

    Any idea how we can solve that, because now we have the problem with SEO and double contents :(

    Thx
    Wayne
     
    Last edited: Aug 4, 2009
  2. lord

    lord Junior Member

    Joined:
    Jan 21, 2009
    Messages:
    176
    Likes Received:
    251
    actually i don't think u have the problem with double content because you're in an iframe and not copy paste

    and as for the code

    use this javascript code in the <head></head> section of your website

    <script>
    if(location.href!=top.location.href){
    top.location.href=location.href
    }
    </script>

    this basically checks if the current url is the same as the one in the address bar, if it's not then it redirects :)

    enjoy his traffic
     
    • Thanks Thanks x 1
  3. wayne1

    wayne1 Newbie

    Joined:
    Jul 13, 2009
    Messages:
    4
    Likes Received:
    0
    Wow, Lord, you're the best :D

    Thank you very much, this works like a charm!!!

    Great, thx! :)

    Wayne
     
  4. lord

    lord Junior Member

    Joined:
    Jan 21, 2009
    Messages:
    176
    Likes Received:
    251
    you welcome :)
     
  5. wayne1

    wayne1 Newbie

    Joined:
    Jul 13, 2009
    Messages:
    4
    Likes Received:
    0
    Ey Lord

    Only if your interessted, here the code we use now ;)

    <script>
    var bRmFrame = true;
    if (self != top) {
    var szRef = document.referrer ? document.referrer : "";
    if (szRef.length) { // exceptions
    if (0 === szRef.indexOf("http://images.google.")) {
    bRmFrame = false;
    }
    }
    if (true === bRmFrame) { top.location.replace(self.location.href); } // overwrite the last history
    }
    </script>

    Regards
    Wayne
     
  6. aylos67

    aylos67 Newbie

    Joined:
    May 22, 2008
    Messages:
    46
    Likes Received:
    1
    good solution..