Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/10/2003, 10:04
daniph
 
Fecha de Ingreso: agosto-2001
Ubicación: Gran Canaria (España)
Mensajes: 430
Antigüedad: 22 años, 8 meses
Puntos: 0
El famoso mod_rewrite

Hola a todos...

Llevo mucho tiempo intentando que el mod_rewrite reescriba mis urls. Ya no se ni que hacer, les dejo aqui los codigos a ver si ustedes me pueden echar una manilla.

Gracias a todos.

.htacces
Código PHP:
Options SymLinksifOwnerMatch 
RewriteEngine on 
Rewritebase 


RewriteRule ^index.htmlindex.php

#News
RewriteRule ^news([1-9][0-9]*).htmlnews.php?id=$1

#Affiliates
RewriteRule ^affiliates.htmlaffiliates.php

#AddNews
RewriteRule ^addnews.htmladdnews.php 
index.php
Código PHP:
<?
function replace_for_mod_rewrite(&$s) {
$urlin = array("'(?<!/)news.php\?id=([0-9]*)'","'(?<!/)affiliates.php'","'(?<!/)addnews.php'");

$urlout = array("news\\1.html","affiliates.html","addnews.html",);

$s preg_replace($urlin$urlout$s); 
return 
$s


echo 
"<html><head><title>Mod_Rewrite</title></head><body>";
echo 
"<a href=news.php?id=1>News 1</a><br>";
echo 
"<a href=affiliates.php>Affiliates</a><br>";
echo 
"<a href=addnews.php>Add News</a><br>";
echo 
"</body></html>";

$contents ob_get_contents(); // store buffer in $contents 
ob_end_clean(); // delete output buffer and stop buffering 
echo replace_for_mod_rewrite($contents); //display modified buffer to screen 
?>
Agradeceria una ayudita con este tema...

Gracias