Ver Mensaje Individual
  #5 (permalink)  
Antiguo 04/03/2008, 15:25
Avatar de marweb
marweb
 
Fecha de Ingreso: marzo-2007
Ubicación: Ciudad de Panama
Mensajes: 125
Antigüedad: 17 años, 1 mes
Puntos: 1
De acuerdo Re: Pasar Variable php con Rewrite

asi mas o menos lo haria yo.

index.php
Código PHP:
<?php 
$caracteresespeciales 
= array(" ""/""*""!""$""%""&""/""("")""=""?""¿""'""á""é""í""ó""ú""ñ""Ñ","©","@","®");

//Hago la consulta
$sop "SELECT * FROM noticias";
//Guardo el resultado
$result mysql_query($sop);

while(
$rnews=mysql_fetch_array($result)) {
$title $rnews["titulo_noticia"];
$namenews str_replace($caracteresespeciales,"_",$title);
?>
<?php 
echo $title;?><br>
<a href="noticia-<?php echo $namenews?>-<?php echo $rnews["idnoticia"]; ?>.html" title="<?php echo $title?>">Ver noticia Completa</a>
<?php 
}                    
?>

noticia.php
Código PHP:
<?
include("dinamic/conex_as.php");

$idnoticia $_GET["idnoticia"];

$conexion=mysql_connect($host,$usuario_db,$pass_usuario_db);
$seldb=mysql_select_db($basedatos);

//Hago la consulta
$sop "SELECT * FROM noticias WHERE idnoticia=$idnoticia";
//Guardo el resultado
$result mysql_query($sop);
while (
$lista mysql_fetch_array($result)){ 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$lista["titulo"];?></title>
</head>

<body>


<?=$lista["titulo"];?>




</body>
</html>
<?
}
mysql_close($conexion);
?>

mod_rewrite .htaccess:


Código:
# .htaccess file 
Options FollowSymLinks
#activacion del motor de escritura
RewriteEngine On
#aca van las reglas de reescritura
RewriteRule ^noticia-(.*)-(.*).html$ noticia.php?idnoticia=$2
__________________
Mario Rios - Webmaster
Diseño web en panama / Real Estate / Abogados de Panama