View Single Post
Old 04-05-2010, 05:05 PM   #2 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

It looks like you're attempting to create the following structure, correct me if I'm wrong;

/classifieds/{$itemid}_{$title}.html

The following should do the trick:

Code:
RewriteEngine On
RewriteRule ^classifieds/([0-9]+)_([^.]+)\.html$ classifieds.php?do=viewitem&itemid=$1&title=$2 [L]
The first capture looks for a set of numbers, which you have accomplished on your own. The second capture after the underscore is looking for any group of characters up until it finds a period. Since it's enclosed in a character range, you don't have to escape it as a control character. Outside of the range it does need to be escaped, as shown here.

Hth

Edit: This allows a lot of freedom in how the title is presented. If you want to ensure that it's only alphabetical, or alphanumerical, replace [^.] with [A-Za-z] or [A-Za-z0-9] or finally [a-z] with NC added at the end [NC,L]
delayedinsanity is offline  
Reply With Quote