Código PHP:
<?php
session_name("url_amigable");
session_start();
$Server=$_SERVER['SERVER_NAME'];
$Script=$_SERVER['PHP_SELF'];
$Variables=$_SERVER['QUERY_STRING'];
if(!empty($Variables) && $_SERVER['REQUEST_METHOD']=='GET' && $_SESSION['Listo']!=1){
$Variable=explode("&",$Variables);
for($i=0;$i<count($Variable);$i++){
$Amigable.="/".str_replace("=",",",$Variable[$i]);
}
$Dir=str_replace(".php","",$Script);
$URL_AMIGABLE="http://".$Server.$Dir.$Amigable."/";
$_SESSION['Listo']=1;
header("Location: $URL_AMIGABLE");
exit;
}
$_URL_BASE="http://".$Server."/pruebas/index.php";
?>
<html>
<head>
<title>URL Amigables</title>
<base href="<? echo "---".$_URL_BASE;?>" target="_top" />
</head>
<body>
<br />
Página con 1 variable: <a href="index.php?categoria=monitores">index.php?categoria=monitores</a>
<br />
</body>
</html>
<?php
switch ($categoria ){
case "monitores":
echo "Se supone que debe de entrar aqui?";
break;
}
$_SESSION['Listo']=0;
?>
Código PHP:
Options +FollowSymLinks
RewriteEngine on
Rewriterule ^(.*)/(.*),(.*)/$ $1.php?$2=$3