0

I am wondering if I can set a redirect at a URL (This part can be done easily I know v).

But this redirect ONLY actually redirects, when the URL is visited. Not when the URL is displayed within an iFrame.

Can this be done at all? Essentially; Visit said URL with redirect implemented in the header; web page redirects to the defined. BUT, a website using that said URL within a iFrame call, it does not redirect.

Basically a page via URL only really accessible & viewable via an iFrame call.

Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
  • I don't think `` redirect can be selective. It will redirect both in iframe and in the parent page. What you could try is to redirect with javascript, there are better possibilities to detect where is the page displayed. – MightyPork Aug 03 '13 at 22:12
  • 1
    http://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t server side detection is not possible. http://stackoverflow.com/questions/725871/server-side-detection-that-a-page-is-shown-inside-an-iframe – Akshay Ransing Aug 03 '13 at 22:15

1 Answers1

2

This is possible via client-side. If you add following code to page onload event:

if (location.href == top.location.href) location.href='http://your_new_url';

the page will redirect to new URL only if it is called as top-level page. If it is called within an IFRAME - the condition will be false and redirect will not happen.

Yuriy Galanter
  • 38,833
  • 15
  • 69
  • 136