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

182
Vistas
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 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