0

Is it possible not to load a page if it is not inside an iframe using php? if it is, can anyone give me a sample how to do it.

i have found something similar but in javascript.

Community
  • 1
  • 1
xiomai
  • 89
  • 4
  • 11
  • The server doesn't have any way of knowing. JS runs on the client, so JS knows best. if you do `header('location: ')` in an `iframe`, the new page is still loaded in said `iframe`... – JKirchartz Mar 28 '12 at 16:46
  • 1
    ok thanks, it's what i was thinking though :) – xiomai Mar 28 '12 at 16:47

3 Answers3

2

Try this: this will hide the direct access of iframe content and hide actual url from users

HTML Page:

<iframe src="direct.php" ></iframe>

direct.php:

header('location: something.php?access_key=dnkjndnj3DDjs');

something.php:

if($_GET['access_key']!='dnkjndnj3DDjs') exit();
/* page content */
pauls john
  • 21
  • 3
0

it is not possible because php is service side scripting, what ever is return from the service can be modify by javascript. The reason why this is can done by javascript is because it is a client side scripting language.

Churk
  • 4,556
  • 5
  • 22
  • 37
0

The server doesn't have any way of knowing. JS runs on the client, so JS knows best. if you do header('location: ') in an iframe, the new page is still loaded in said iframe...

JKirchartz
  • 17,612
  • 7
  • 60
  • 88