Using RegEx to rewrite/"pretty" URLs

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
calrockx
Forum Newbie
Posts: 6
Joined: Mon Apr 28, 2008 11:32 am

Using RegEx to rewrite/"pretty" URLs

Post by calrockx »

I'm trying to make some "pretty" URLs on a website, but ehh....what I've got isn't working.



The site URL could be anything from

http://vitanova.charlesrubinoff.com/ind ... esidential

to

http://vitanova.charlesrubinoff.com/ind ... age=01.jpg



So there are up to three queries... section, category, and image.



Only when the user is in a Section part of the site (as in vitanova.com.com/?section=residential and not vitanova.com/?page=contact), I'd like the URL to be formatted like this:

vitanova.com/galleries/residential/bathrooms/01



So I'm making it look like they're in a galleries subfolder that doesn't really exist.

Here's what I've got, and it's not working...

Rewrite Rule ^galleries/([^/]+)/([^/]+)?/?([0-9][0-9]+)?$ /index.php?section=$1&category=$2&image=$3 [L]



Any ideas?
Post Reply