Results 1 to 9 of 9

Thread: Redirect Iframe when loaded directly

  1. #1
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Redirect Iframe when loaded directly

    I'm using an Iframe on 1 page, without problems, however I like to built in some "security", to make sure the user sees what I want them to see....
    When user goes directly to the iframe source, I like to have that page redirect to the page that contains the Iframe,

    Example:
    page 123.xxx contains the iframe. In this iframe it loads page 456.xxx

    Now when a user goes directly to 456.xx, I like that page to redirect automatically, so 123.xxx will be loaded.
    Exception:
    As some users might not be able to view iframes, I show the user a link that I have in the iframe code, to "click here" and this will open the page 456.xxx in a new window.

    I was maybe thinking of using the referral link...
    Something like: If referral link is 123.xxx, show content, else redirect to 123.xxx
    Anyone ideas on how to accomplish this?

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    .htaccess:

    Code:
    Redirect /123.xxx http://domain.com/456.xxx
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your fast reply!
    That's what I thought of as well BLiZZaRD, however I do not have access to the .htaccess on my shared hosting company
    My old pages are redirecting via my 404 page, but that only works of cos, when the old page no longer exists...
    Any alternatives?

  4. #4
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    With javascript placed in 456.xxx this works:

    <script language="JavaScript"><!--
    var ref = document.referrer;
    if (ref.indexOf('www.myurl.com') != -1)
    {}
    else
    window.location.href = 'http://www.myurl.com/123.xxx';
    //--></script>

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by worldofrugs View Post
    Thanks for your fast reply!
    That's what I thought of as well BLiZZaRD, however I do not have access to the .htaccess on my shared hosting company
    My old pages are redirecting via my 404 page, but that only works of cos, when the old page no longer exists...
    Any alternatives?
    You can upload your own .htaccess file(s), unless specifically forbidden by your host. They have a master one, sure, and control of the httpd conf files, but your .htaccess should be just fine.

    Who is your host?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    My host is GoDaddy

    Running on a windows server.. They only support .htaccess for their Linux servers..
    Last edited by worldofrugs; 09-09-2008 at 03:05 PM.

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Oh... problem number one... LOL.

    Might I suggest you look into site5 hosting

    If worldofrugs' post doesn't help there are php alternatives as well.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    LMAO!
    I so much agree that GoDaddy is the no.1 problem right there... However, I have no say in changing the hosting account, so pretty much my hand are tied on that one....
    This was the reason I was looking for an alternative.
    As mentioned, the script version I have now works fine, but of cos is not the perfect solution.
    I will be looking into the site5 hosting for personal use Thanks for that tip!

  9. #9
    Join Date
    Sep 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Hey Guys,

    I have a similar issue, and .htaccess is a viable option on my server.

    The only problem with that is, the content that I'm linking to has an iframe in the page which CONTAINS that original page (which gets redirected). That means that its an infinite loop and nothing is resolved (if the google bots find it before I fix it they will be very unhappy with me haha.

    So, to restate the problem, we have HTML pages within HTML pages, we want people who get linked directly to the inside content, to be redirected to the page that HOLDS that content.

    Any ideas?

    SDO

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
  •