www.webdeveloper.com
Results 1 to 4 of 4

Thread: Redirect external traffic to iframed version

  1. #1
    Join Date
    Jul 2011
    Posts
    6

    Thumbs up Redirect external traffic to iframed version

    Hi, all,

    This is maybe more of a web server question than a php one...

    I have a site that houses its e-commerce component (a zencart) in an iFrame. I would like to find a way to redirect external traffic to the page with the iFrame; essentially to re-house the content. I have a general guess at the steps, but I think I'm reinventing a wheel, and my php is novice... Has anyone done this?

    Thanks, Fred

  2. #2
    Join Date
    Oct 2007
    Posts
    366
    If I understand what you're looking for, I don't think PHP can do it but JS can. In the zencart page, (Probably index.php or in a header file in the template)

    try something like:

    HTML Code:
    <script>
    if (top.location = location){top.location = "http://www.mysite.com/webstore"}
    </script>
    Not perfect, but maybe good enough.

  3. #3
    Join Date
    Jul 2011
    Posts
    6

    hmmm

    I appreciate the reply; I think that solution will work for me in a basic way. I'm pretty sure I still need to use a session variable or POST or something if I want to tell the original (wrapped) page the actual URL they want put into the iframe (rather than just dumping them to the store-front), though. Any thoughts?

    Thanks,
    Fred

  4. #4
    Join Date
    Oct 2007
    Posts
    366
    I think I have tried sessions, and had trouble picking up sessions from frame to frame.

    You can change the url in the redirect by echoing it with a dynamic query string.
    PHP Code:
    <?php
    $qs
    =$_SERVER['QUERY_STRING'];
    echo(
    '
    <script>
    if (top.location = location){top.location = "http://www.mysite.com/webstore/?'
    .$qs.'"}
    </script>
    '
    );
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles