![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
08/02/2008, 08:41
|
| | Fecha de Ingreso: octubre-2004 Ubicación: Uruguay
Mensajes: 386
Antigüedad: 20 años, 4 meses Puntos: 4 | |
Re: detectar dominio padre php Cita:
Iniciado por jcxnet Yo uso esta para detectar el dominio de una página, pero la puedes modificar para que le envíes la URL y te devuelva lo que necesitas: Código PHP: function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2));} function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); $URL = $protocol."://".$_SERVER['SERVER_NAME']."/"; $pos = strpos($URL, "www."); if ($pos === false){ $pos = strlen("http://"); $URL = substr($URL,0,$pos).'www.'.substr($URL,$pos); } return $URL; }
![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif) Este me ha gustado mas. pero no funciona para subdominios |