Mostrar página en blanco en carga directa (PHP)

I currently use an external service for a price comparison unit I have on one of my sites. The way you load the price comparison block is via javascript:

<script type="text/javascript" language="javascript" src=";ecu_uid=101734"></script>

If you were to paste the above code into a html page, you would see a block of prices, more info buttons etc. However, if you loaded the source page directly, it shows no content and a completely blank page:;ecu_uid=101734

I am looking to write some code for another site I run and would like it to work like the example above. I.E. when I load an external php page via javascript, it will show it on the webpage. If you followed the link and loaded the external page it would show a blank page.

How would you go about this? Is it some special php code, or a trick with htaccess or similar?

Cualquier ayuda sería muy apreciada.

preguntado el 10 de marzo de 12 a las 15:03

when I change the url to (ie. change the &amp to &) it works just fine - loading it directly -

My apologies. That was a rookie error on my part! Is there any way to do the above however? As it is still something that I would like to try and implement. -

scibuff's point is correct -- entities make sense in HTML code only. When typing URL in location bar of browser, corresponding character (&) should be used instead of its entity (&amp;). -

2 Respuestas

Most likely what you want is just referer request header check:


respondido 10 mar '12, 15:03

A referrer check does indeed achieve the desired effect, but note that a Referer header can be very easily spoofed, so it is by no means a solid "protection". Also, some users may have configured their clients to omit or manipulate referrers, so the script wouldn't work for them even when it is embedded into a page. - otro Código

They are most likely checking the HTTP_REFERER value in the $_SERVER superglobal, and returning a blank page when the referrer is not the correct site.

respondido 10 mar '12, 16:03

Thank you for the help. Although I have made a mistake above when trying to load the direct link (should of just used the & on its own), I would still like to try and come up with a solution. - paquet

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.