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

197
Visualizações
How do I limit access to a page only through redirect from another page

I have two web pages, index.html and home.html. I'm trying to make home.html can only be accessed from index.html so that if a user inputs www.mywbpage.home.html, they'll be redirected to an error page or to index.html..

I linked index.html to home.html with a JS button.

Tried searching all over but the PHP, JS and .htaccess codes I got didn't work...

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

This can be done without server side, but you know this is a bit sketchy.

index.html

var value = "visited";    // or the date of visit!
localStorage.setItem('my_flag', "visited");

home.html

var value = localStorage.getItem('my_flag');
if (value != "visited") {
    window.location = "index.html";
}
localStorage.removeItem("my_flag");
about 4 years ago · Juan Pablo Isaza Relatório

0

you can use sessionStorage to do that first on the load index page put

sessionStorage.setItem('home', 'true');

second, if you are on the home page check if

sessionStorage.getItem('home')=="true"

if it is true let him there else redirect

about 4 years ago · Juan Pablo Isaza Relatório

0

not sure if this helps, but a simple approach would be:

  1. Convert index.html and home.html to index.php and home.php, in its simple form just renaming the file should be enough.

  2. In home.php, add the check for HTTP_REFERER header like below:

<?php
$prev_url = $_SERVER['HTTP_REFERER'];
if($prev_url != "/") {  /* or use fully qualified url for index */
    header("Location: /");
    exit;
}
?>
<!-- here on put the home.html content -->

*Note This is highly insecure and not recommended as HTTP_REFERER can easily be spoofed

about 4 years ago · Juan Pablo Isaza Relatório
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