Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
How to disallow access to a website without accessing a certain link?

I am trying to disallow access to https://example2.com without accessing https://example1.com first.

Solution #1. So My initial solution is to check $_SERVER['HTTP_REFERER'] of the example2.com,

if ($_SERVER['HTTP_REFERER'] != "example1.com") { redirect to example1.com };

but the solution above will not work for hackers as they can just use javascript or python to add <a href="example2.com"> element on the example1.com and then auto click the <a> tag to let the browser know that the referer is from example1.com.

Solution #2. My second solution is to send POST data from example1.com to example2.com. Like this:

<form method="post" action="example2.com">
    <input id="autoSubmit" name="veri" value="DoNotCheatPleaseWeWillBanYouGodIsWatchingYouHaveMercy">
</form>

then on example2.com

if(htmlspecialchars($_POST['veri']) != "DoNotCheatPleaseWeWillBanYouGodIsWatchingYouHaveMercy"){
    header('Location: example1.com');
    die();
}

In the code above, if you access example2.com directly, then it will redirect you to example1.com. So hackers can not add this a tag element on example1.com: <a href="example2.com">

but again, solution #2 was also a failure as any hacker can add a form element on the first website (example1.com) using javascript or python. <form method="post" action="example2.com"><input id="autoSubmit" name="veri" value="DoNotCheatPleaseWeWillBanYouGodIsWatchingYouHaveMercy"></form>

I am out of ideas even if I combine both ( Send POST and Check referer ), hackers can still access my other website directly. I am thinking of sending PHP sessions or cookies to example2.com but I still couldn't do it or maybe not possible. If you guys have any ideas please share. Thanks.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda