Re: Geting feet wet with REGEX and url rewriting (maybe a bit 0T)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/4/06, Ryan A <genphp@xxxxxxxxx> wrote:
RewriteRule ^blog-([0-9]+).html$
index.php?act=blog&id=$1

This is fine, but you should really be escaping the
"." (by writing it as  "\."). Otherwise, it matches any
character, not just the literal period.

mysite.com/blog/blog-2-the_great_escape.html
which should be processed like this:
index.php?act=blog&id=$1&string=$2

going through the regex tutoral I see I need to use
"$2" for the second parameter and "$3" etc if i keep
adding parameters but still getting stumped on the
first regex part (eg: ^blog-([0-9]+).html$ )

You just need to add another pair of parenthesis
to get the second match. For your case, it'll be
something like (untested):

RewriteRule ^blog-([0-9]+)-([^\.]+)\.html$
index.php?act=blog&id=$1&string=$2

Rabin

--
http://rab.in

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux