Foros del Web » Programando para Internet » PHP »

Ayuda con este script php

Estas en el tema de Ayuda con este script php en el foro de PHP en Foros del Web. Hola, a ver si me puede ayudar con esto, tengo este script en php para redireccionar al usuario de acuerdo con la pagina que haya ...
  #1 (permalink)  
Antiguo 21/02/2011, 07:53
 
Fecha de Ingreso: febrero-2011
Mensajes: 3
Antigüedad: 13 años
Puntos: 0
Ayuda con este script php

Hola, a ver si me puede ayudar con esto, tengo este script en php para redireccionar al usuario de acuerdo con la pagina que haya ingresado, pero no logro hacer que ande bien.

<?php

if ($_SERVER["SERVER_NAME"] = 'lubricentrodonpepe.com.ar')
{
header('location:http://lubricentrodonpepe.com.ar/lubridonpepe/');
}

if ($_SERVER["SERVER_NAME"] = 'codigoargento.com.ar')
{
header('location:http://www.codigoargento.com.ar/codar/');
}

?>

Con ese script siempre me lleva a http://www.codigoargento.com.ar/codar/' por mas que ingrese lubricentrodonpepe.com.ar
Para probar hice un echo del $_SERVER["SERVER_NAME"] y tira bien las direcciones, pero no se por que no redirecciona bien.
  #2 (permalink)  
Antiguo 21/02/2011, 07:58
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 1 mes
Puntos: 288
Respuesta: Ayuda con este script php

cuando llegas a esta pagina hace var_dump($_SERVER)
a ver cual es el valor real de $_SERVER["SERVER_NAME"]
  #3 (permalink)  
Antiguo 21/02/2011, 08:07
 
Fecha de Ingreso: febrero-2011
Mensajes: 3
Antigüedad: 13 años
Puntos: 0
Respuesta: Ayuda con este script php

Probe lo que me dijiste y me tira esto

array(43) { ["PROXY_ADDR"]=> string(12) "209.190.85.3" ["VH_GECOS"]=> string(25) "lubricentrodonpepe.com.ar" ["VH_PATH"]=> string(41) "/home/vol9/eshost.es/eshos_7122435/htdocs" ["SERVER_ROOT"]=> string(41) "/home/vol9/eshost.es/eshos_7122435/htdocs" ["PHP_DOCUMENT_ROOT"]=> string(41) "/home/vol9/eshost.es/eshos_7122435/htdocs" ["PERL_RLIMIT_DATA"]=> string(7) "600:900" ["PERL_RLIMIT_AS"]=> string(7) "600:900" ["PERL_RLIMIT_CPU"]=> string(2) "15" ["PERL_RLIMIT_CORE"]=> string(1) "0" ["PERL_RLIMIT_RSS"]=> string(2) "60" ["PERL_RLIMIT_FSIZE"]=> string(1) "6" ["PERL_RLIMIT_NOFILE"]=> string(3) "200" ["RLIMIT_AIO_OPS"]=> string(1) "3" ["HTTP_HOST"]=> string(25) "lubricentrodonpepe.com.ar" ["HTTP_ACCEPT"]=> string(90) "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" ["HTTP_USER_AGENT"]=> string(118) "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13" ["HTTP_ACCEPT_ENCODING"]=> string(17) "gzip,deflate,sdch" ["HTTP_ACCEPT_LANGUAGE"]=> string(14) "es-ES,es;q=0.8" ["HTTP_ACCEPT_CHARSET"]=> string(30) "ISO-8859-1,utf-8;q=0.7,*;q=0.3" ["HTTP_COOKIE"]=> string(170) "e3c5e47d3ae4cdca3eb3c44f09a28005=cfc25cced5728839 8cc5d0ca26cab279; b7a68eecd799964cd548b50f8fcf443f=28d7bfae3bd4847e2 9a5e57a03f27d77; style_color=7; font_size=mediumfonts" ["HTTP_VIA"]=> string(55) "1.1 demil1.byetcluster.com:80 (Lusca/LUSCA_HEAD-r14756)" ["HTTP_X_FORWARDED_FOR"]=> string(13) "190.224.71.55" ["HTTP_CACHE_CONTROL"]=> string(14) "max-age=259200" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["PATH"]=> string(13) "/usr/bin:/bin" ["SERVER_SIGNATURE"]=> string(0) "" ["SERVER_SOFTWARE"]=> string(6) "Apache" ["SERVER_NAME"]=> string(25) "lubricentrodonpepe.com.ar" ["SERVER_ADDR"]=> string(14) "209.190.85.191" ["SERVER_PORT"]=> string(2) "80" ["REMOTE_ADDR"]=> string(13) "190.224.71.55" ["DOCUMENT_ROOT"]=> string(41) "/home/vol9/eshost.es/eshos_7122435/htdocs" ["SERVER_ADMIN"]=> string(0) "" ["SCRIPT_FILENAME"]=> string(51) "/home/vol9/eshost.es/eshos_7122435/htdocs/index.php" ["REMOTE_PORT"]=> string(4) "6486" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.0" ["REQUEST_METHOD"]=> string(3) "GET" ["QUERY_STRING"]=> string(0) "" ["REQUEST_URI"]=> string(1) "/" ["SCRIPT_NAME"]=> string(10) "/index.php" ["PHP_SELF"]=> string(10) "/index.php" ["REQUEST_TIME"]=> int(1298297043) }
  #4 (permalink)  
Antiguo 21/02/2011, 08:18
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 1 mes
Puntos: 288
Respuesta: Ayuda con este script php

ok, pero busca el que te interesa a vos

var_dump($_SERVER["SERVER_NAME"])
  #5 (permalink)  
Antiguo 21/02/2011, 08:26
 
Fecha de Ingreso: febrero-2010
Mensajes: 818
Antigüedad: 14 años, 1 mes
Puntos: 55
Respuesta: Ayuda con este script php

dos cosas, en el if tenias = en ves de == y cambie el segundo if por un elseif auque cuando cambia el header se salga del script.

Código PHP:
<?php

if ($_SERVER["SERVER_NAME"] == 'lubricentrodonpepe.com.ar')
{
header('location:http://lubricentrodonpepe.com.ar/lubridonpepe/');
}
elseif (
$_SERVER["SERVER_NAME"] == 'codigoargento.com.ar')
{
header('location:http://www.codigoargento.com.ar/codar/');
}

?>
  #6 (permalink)  
Antiguo 21/02/2011, 08:36
 
Fecha de Ingreso: febrero-2011
Mensajes: 3
Antigüedad: 13 años
Puntos: 0
Respuesta: Ayuda con este script php

Gracias DeathEmpire, probe como vos me dijiste y anduvo!
Muchas gracias.

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:58.