View Full Version : Redirect Iframe when loaded directly
worldofrugs
09-08-2008, 06:54 PM
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?
BLiZZaRD
09-08-2008, 07:08 PM
.htaccess:
Redirect /123.xxx http://domain.com/456.xxx
worldofrugs
09-08-2008, 07:26 PM
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?
worldofrugs
09-08-2008, 08:40 PM
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>
BLiZZaRD
09-09-2008, 02:37 PM
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?
worldofrugs
09-09-2008, 02:58 PM
My host is GoDaddy :eek:
Running on a windows server.. They only support .htaccess for their Linux servers..
BLiZZaRD
09-09-2008, 03:07 PM
Oh... problem number one... LOL.
Might I suggest you look into site5 hosting (http://www.site5.com/in.php?id=10585-1)
If worldofrugs' post doesn't help there are php alternatives as well.
worldofrugs
09-09-2008, 03:18 PM
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!
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
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.