[thelist] SEO and dynamic URL's

Joshua Olson joshua at waetech.com
Fri Jul 9 10:31:25 CDT 2004

> -----Original Message-----
> From: sbeam
> Sent: Friday, July 09, 2004 10:40 AM
> On Thursday 08 July 2004 05:42 pm, Joshua Olson wrote:
> > http://www.houseoffusion.com/cf_lists/message/4/33724/
> >
> > Using URL rewriting tools, this new URL structure could be used in
> > place of the original quite easily with only a single rule... aka 1
> > line of code, literally.
> ok, curiosity is killing me - what would your one-liner be, may I ask?
> I've tried to parse this kind of thing, what you might call
> "slash-delimited" query strings, but what to do if there is a slash in
> one of the values? backslash-escape it? convert it to a token?
> do something like the following (psuedo-code):
>   parms = split('/', HTTP_PATH_INFO);
>   for (i=0; i<count(parms); i+=2) {
>     QUERY_PARAMS[parms[i]] = parms[i+1]
>   }
> add in special acrobatics to deal with the escaped slashes and its a lot
> more than one line...?

Here's a rule that converts:




RewriteRule /cf_lists/message/([\d]+)/([\d]+)[/?]{0,1}.*([^?]*)
/cf_lists/message.cfm/\?threadid=$1&messageid=$2&$3 [I,U]

That rule is set up for ISAPI_ReWrite, but should be very similar to the
mod_rewrite rule.  The [I,U] at the end tells the parser to [I]gnore case,
and to [U]nmunge the URL for the log files (meaning that the line gets put
into the server log files in it's unaltered state)  This rule is also set up
so that any additional URL attributes that are passed to the file are
attached to the end of the new URL as well and not discarded.

See, one line!

If the file message.cfm ever changed names (for example, put in a beta
version of the file), all I'd need to do was to change the rule to point to
the new file.  None of the links would need to change.

You also asked about slashes in one of the values... well, I'd hope that
it'd be escaped using URL encoding.  Otherwise, all bets are off!
Generally, I use this technique when passing around a controlled set of
tokens only, like numeric id's, or words that are specifically designed to
be URL safe.  If I need to pass around unsafe values, I'd opt to make it a
normal URL parameter in the querystring.  For most pages you want indexed, I
think this would be a moot point, though.

Joshua Olson
Web Application Engineer
WAE Tech Inc.

More information about the thelist mailing list