
24/09/2009, 12:38
|
| | Fecha de Ingreso: septiembre-2009
Mensajes: 7
Antigüedad: 15 años, 5 meses Puntos: 0 | |
Redirección y extensión php Hola amigos, tengo una pregunta para hacer una redirección, hago la canonicalizacion con este código,
$target_host = "www .ejemplo.com"; // www .ejemplo.com or ejemplo.com
$redirect = false;
$path = $_SERVER['REQUEST_URI'];
$host = $_SERVER['HTTP_HOST'];
// Checking host
if ($host != $target_host) {
$redirect = true;
$host = $target_host;
}
$url = $host.$path;
// Checking path
$pattern = "^(.*)(/index\.php)$^";
preg_match_all($pattern, $url, $match);
if ($match[0][0] != "") {
$redirect = true;
$url = $match[1][0] . "/";
}
// Redirect
if ($redirect){
header('HTTP/1.1 301 Moved Permanently');
header('Location:http ://'.$url);
}
hasta aquí no tengo problemas. Ahora lo que quiero es quitarle la extesión /archivo.php para que se muestre la url simplemente como /archivo, ahora ocupo esto:
RewriteEngine on
RewriteRule ^archivo$ archivo.php [L]
Quisiera saber como hacerlo para todos mis archivos .php y también como redirigirlos para que no sea considerado como contenido duplicado.
Muchas gracias amigos foristas... |