Pregunta:
Fecha: 27-02-2020 02:28:08
(En Inglés)
$page = 1;
header("Location: https://mydomain/home?page=".$page);
?>
This is my php code.
It is working on my local server- xampp.
but it is not working in planetHoster.
what is problem?
Please help me.
Thank you for your help. Votos: 0 - Respuestas: 5 - Vistas: 7 Compartir en: Google Facebook Twitter LinkedIn Link
PHP Redirect function is not working in planetHoster.[Resuelta]
<?php$page = 1;
header("Location: https://mydomain/home?page=".$page);
?>
This is my php code.
It is working on my local server- xampp.
but it is not working in planetHoster.
what is problem?
Please help me.
Thank you for your help. Votos: 0 - Respuestas: 5 - Vistas: 7 Compartir en: Google Facebook Twitter LinkedIn Link
Respuestas:
-
Fecha: 27-02-2020 05:35:12 ¿Tienes algún mensaje de error? (revisa los logs) ¿Hay alguna línea de código HTML (o que genere código HTML) antes de la redirección? Si la hay, esa es la causa y generalmente produce un error que dice "headers already sent"
Do you have any error message? (check your logs) Is there any HTML code (or generated HTML code) before the redirection? If there is, that might be causing your problem and the error reads something like "headers already sent" Votos: 0 - Link respuesta -
Fecha: 28-02-2020 15:21:27 It does not display error. it displays blank page. Votos: 0 - Link respuesta
-
Fecha: 28-02-2020 16:14:46 Is there any other code after the redirection? Usually you avoid processing extra code by adding a die() function just after the redirection:
<?php $page = 1; header("Location: https://mydomain/home?page=$page"); die(); ?>
Also (not sure if it makes any difference on this case,though) I got rid of the concatenation operator (dot) and moved the $page variable inside the qoutes. Votos: 1 - Link respuesta -
Fecha: 02-03-2020 13:24:18 That's odd. Check server logs to see if the request is reaching the target.
Also do as Juan Vasquez suggested and add a die() statement right after the header statement.
Also to discard any issues on the receiving end make sure that browsing directly to the URL works. Votos: 0 - Link respuesta -
Fecha: 03-03-2020 05:01:11 Probably i'm stating the obvious but, is your page reachable via https? (can you open that address using you browser?
Also, searching in stackoverflow (praise be StackOverflow) I found that some hosting providers sent headers on their own, preventing this type of redirection, so you can also try<script type="text/javascript"> window.location.replace("https://tuweb.com/pagina.html"); </script>or even<meta http-equiv="Location" content="http://tuweb.com/pagina.html"/>
Votos: 0 - Link respuesta
Para participar activamente de la comunidad primero debes autenticarte, ingresa al sistema.Iniciar Sesión
