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.html$ index.php
#News
RewriteRule ^news([1-9][0-9]*).html$ news.php?id=$1
#Affiliates
RewriteRule ^affiliates.html$ affiliates.php
#AddNews
RewriteRule ^addnews.html$ addnews.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
?>
Gracias