Non-numerical values

Discuss practical ways rearrange URLs using mod_rewrite.

Non-numerical values

Postby killet » Wed Aug 06, 2008 8:39 am

Hi I am trying to use mod_rewrite on the following url.

/q.php?type=people&book=13

I would like it to rewrite to question/people/13

The thing I can't get is there are multiple types, and its not a numerical value. So I don't know how to set my mod rewrite. Any help is greatly appreciated.

Cheers~
killet
 
Posts: 3
Joined: Wed Aug 06, 2008 8:25 am

Postby richardk » Wed Aug 06, 2008 3:29 pm

How many other types?
Does "book" change?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby killet » Wed Aug 06, 2008 8:00 pm

No, only the type=$VALUE changes. The &book=# is just a numeric value.
killet
 
Posts: 3
Joined: Wed Aug 06, 2008 8:25 am

Postby richardk » Thu Aug 07, 2008 12:49 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^question/([^/]+)/([0-9]+)/?$ /q.php?type=$1&book=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby killet » Fri Aug 08, 2008 10:22 am

worked great, thank you!
killet
 
Posts: 3
Joined: Wed Aug 06, 2008 8:25 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 49 guests

cron