Rewrite - Problem with the second var

Discuss practical ways rearrange URLs using mod_rewrite.

Rewrite - Problem with the second var

Postby Pablop » Thu Aug 21, 2008 5:07 pm

Hi! First of all, sory for my english!

First, i´ve this:

Code: Select all
RewriteEngine On
RewriteBase /
Options +FollowSymlinks
rewriteRule ^([^/]+).html?$ /index.php?nombre=$1 [L]


and i call it:

<a href="/'.urls_amigables($row["nombre"]).'.html">'.$row["nombre"].'</a>

At this step, no problem! work perfectly.

Then, i need to add another var. The file that i need to call is: index.php?nombre=XXX&titulo=XXX

I try:

Code: Select all
rewriteRule ^([^/]+)/([^/]+).html?$ /index.php?nombre=$1&titulo=2 [L]

I call it:

<a href="'.urls_amigables($nombre).'/'.urls_amigables($row["titulo"]).'.html">Leer Mas</a>

But don´t work. I want call a page that look somethink like:

www.misite.com/NOMBRE/TITULO.html

This, when the two vars are set. NOMBRE and TITULO. But, when only NOMBRE is set, i need that look:

www.misite.com/NOMBRE.html


Thanks!
Pablop
 
Posts: 1
Joined: Thu Aug 21, 2008 5:06 pm

Postby richardk » Sat Aug 23, 2008 9:56 am

2 should probably be $2. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([^/]+)\.html$         /index.php?nombre=$1           [QSA,L]
RewriteRule ^([^/]+)/([^/]+)\.html$ /index.php?nombre=$1&titulo=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 29 guests

cron