Using mod_rewrite for dynamic url

rubencit

New Member
Messages
28
Reaction score
1
Points
0
.htaccess
<ifmodule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)/$ index.php?var1=$1&var2=$2&var3=$3 [L]
RewriteRule ^(.*)/(.*)/$ index.php?var1=$1&var2=$2 [L]
RewriteRule ^(.*)/$ index.php?var1=$1 [L]

#redirection page if there are problems
ErrorDocument 404 /error404.phtml
</ifmodule>

root file index.php

<?php
@$parametro1 = $_GET['var1'];
@$parametro2 = $_GET['var2'];
@$parametro3 = $_GET['var3'];
?>
<head>
<html>
<body>
<?php
if(!$parametro1) echo "This is the news section with no parameters";
else if(!$parametro2) echo "Parameter1: $parametro1";
else if(!$parametro3) echo "Parameter1: $parametro1 <br/>Parameter2: $parametro2";
else echo "Parameter: $parametro1 <br/>Parameter2: $parametro2 <br/>Parameter3: $parametro3";
?>
</body>
</html>
</head>
 

papichulo_carioco

Community Advocate
Community Support
Messages
1,400
Reaction score
12
Points
0
no entiendo lo que quieres (aunque intuyo algo). Por otro lado no te costaria nada meter el codig entre sus tags correspondientes (para ello existen los botones del editor) y de esa manera no se corre el riesgo de dañar el foro ;)
 
Top