Pretty simple

Discuss practical ways rearrange URLs using mod_rewrite.

Pretty simple

Postby ready4god2513 » Fri Aug 29, 2008 3:19 pm

Hi, I am pretty new to apache, and as such, to mod_rewrite. But what I need is pretty simple, I think.

I am wondering how to convert-
http://www.mysite.com/12/testinfo

to
http://www.mysite.com/?pageId=12

Where both 12 and testinfo can vary. 12 can be any number, which I have learned would be written as ([0-9]+]. But really I don't care about anything other than that. The /testinfo is just so that the user knows where they are.

I really appreciate any help.

Thanks,
Brandon
ready4god2513
 
Posts: 2
Joined: Fri Aug 29, 2008 3:09 pm

Postby ready4god2513 » Fri Aug 29, 2008 3:37 pm

Ok. I think I got it.
Code: Select all
RewriteRule ^([0-9]+)/([a-zA-Z0-9-&/]+)$ /index.cfm?pageId=$1
ready4god2513
 
Posts: 2
Joined: Fri Aug 29, 2008 3:09 pm

Postby richardk » Sat Aug 30, 2008 11:10 am

You should add the L flag to stop processing when the rule is matched
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([0-9]+)/[a-z0-9-&/]+$ /index.cfm?pageId=$1 [NC,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 8 guests

cron