Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda