I have a page i only want to be visible if it is shown in a iframe.
Is this possible in PHP, htaccess or something? how?
I would prefer a solution in PHP
Thanks!
Frames are client side only so you can't check it through PHP or .htaccess. You can check it in Javascript. See this thread:
How to identify if a webpage is being loaded inside an iframe or directly into the browser window?
EDIT
Here's an example that would redirect for you. It's straight Javascript but if you were doing this with jQuery you could write the same function into document.ready
<script>
function check_frame() {
if( top === self ) { // not in a frame
location.href = "/link/to/some/url"; // either the frameset or an error.
}
}
</script>
<body onLoad="check_frame()">
... normal code for your page here ...
</body>
Note that the page can still be a PHP page, it would just need to output that bit of Javascript.