Re: Geting feet wet with REGEX and url rewriting (maybe a bit 0T)
| From: | Rabin Vincent | Date: | Thu, 04 May 2006 16:32:49 +0000 |
| Subject: | Re: Geting feet wet with REGEX and url rewriting (maybe a bit 0T) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235533@lists.php.net to get a copy of this message | ||
On 5/4/06, Ryan A <genphp@yahoo.com> wrote:
RewriteRule ^blog-([0-9]+).html$ index.php?act=blog&id=$1This 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