Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/02/2012, 04:21
albertrc
 
Fecha de Ingreso: febrero-2009
Mensajes: 443
Antigüedad: 15 años, 3 meses
Puntos: 1
redireccion de index.html o index.php al dominio

en index.php me funciona pero en index.html no me tendria que hacer la redirrecion igualmente

//url inicial
//http://seophp.example.com/tema4/la-eliminacion-de-index.php/index.php
//redirecciona url
//http://seophp.example.com/tema4/la-eliminacion-de-index.php/


me sale el siguiente error
Not Found

The requested URL /tema4/la-eliminacion-de-index.php/index.html was not found on this server.
Apache/2.2.21 (Fedora) Server at seophp.example.com Port 80



el fichero se llama index.php
<?php
//redireccionar la petición actual si es necesario
require_once 'include/url_redirect.inc.php';
//redireccionar las peticiones a index.php y index.html hacia la raíz
fix_index_url();
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>redireccion correcta</title>
</head>
<body>
<h1>redireccion correcta</h1>
</body>
</html>


el fichero se llama url_redirect.inc.php y esta dentro de una carpeta include
Código PHP:
Ver original
  1. <?php
  2. //redireccionar peticiones a index.php y index.html hacia la raíz
  3. function fix_index_url()
  4. {
  5.   //si la petición se realiza para index.php redireccionamos a ./
  6.   if (preg_match('#(.*)index\.(html|php)$#', $_SERVER['REQUEST_URI'], $captures))
  7.   {
  8.     //realizar una redirección 301 al nuevo URL
  9.     header('HTTP/1.1 301 Moved Permanently');
  10.     header('Location: ' . $captures[1]);
  11.   }
  12. }
?>

dentro de la carpeta tengo un fichero que se llama config.inc.php
Código PHP:
Ver original
  1. <?php
  2. // dominio de sitio; sin '/' final !
  3. define('SITE_DOMAIN', 'http://seophp.example.com');
  4. ?
>