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

190
Visualizações
How to avoid loop when redirecting WordPress post?

I have a redirection problem on WordPress, I want to show a different page to users that come from search engines instead of those who come directly

Have the "Insert PHP Code Snippet" plugin for this purpose.

The script is :

<?php 
 
##Begin of conditions
 
##End of conditions

## If conditions Met above

If(isUserValid() === "true") {
    header("Location: https://example.com"); }  #external URL

## If conditions Not Met above
 
else 
{    
    header("Location: https://example.net/post"); } #wordpress post

So the problem here, the PHP code is inserted in that post https://example.net/post If the conditions are okay, the redirection goes smooth But when the conditions aren't met, I'm getting a redirection loop and error. Because the header is the same where I've put the code.

Is there a way to write a code that can disable the PHP code after the first redirection?

For SEO I need the redirection to be done to the same post, to avoid losing ranking.

EDIT: I need to replace this line

header("Location: https://example.net/post"); } #wordpress post

With another line, that will let you stay on the same page if conditions aren't met. That will fix my issue.

Thank you

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