Forum Moderators: phranque

Message Too Old, No Replies

RewriteMap using "long name" and $1

         

maggi

8:03 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



I am using a codinglist.txt as:
longnamearticlename111 articlecode111
longnamearticlename222 articlecode222

I want to use in the cgi the articlecode _and_ the longnamearticlename222
RewriteRule ^/([^_]*)\.html$ /cgi-bin/go.cgi?articlecode111=${icaolist:$1}&name=? [L]

In mod_rewrite I have not found a representation for the longnamearticlename****?
Or is there a trick to work with RewriteCond and $N?
Thank you, Maggi

jdMorgan

11:18 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



maggi,

It would be quite helpful if you could provide a "before and after" sample of the original and rewritten URLs, using "example.com" as the domain name.

Jim

maggi

7:30 am on Feb 17, 2004 (gmt 0)

10+ Year Member



I am using a codinglist.txt as a translation from:
# longname -> citycode
Alabama-City 111
Alabama-Downtown 111
Alabama-Mystreet 111
Boston-City 222
Boston-Downtown 222

The goal is to use the codinglist.txt to translate longname to citycode, but to let the cgi-string also transfer the longname to the page.html for usage as a text string.

[example.com...] -> /cgi-bin/go.cgi?citycode=111&longname=Alabama-Downtown
[example.com...] -> /cgi-bin/go.cgi?citycode=111&longname=Alabama-Mystreet

In mod_rewrite I have not found a representation to "catch" the "longname" as the first element in the RewriteMap for a later usage in the cgi string.
Or might I use RewriteCond to catch the "longname" and use $N in the cgi-string?

RewriteCond xyz?
RewriteRule ^/(.*)\.html$ /cgi-bin/go.cgi?citycode=${codinglist:$1}&longname=$N

jdMorgan

4:41 pm on Feb 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



maggi,

If the "longname" in your first example incoming URL is "Alabama-Downtown", then I believe that all you need to do is to repeat the $1 in your substitution string:


RewriteRule ^/([^.]*)\.html$ /cgi-bin/go.cgi?citycode=${codinglist:$1}&[b]longname=$1[/b]

The content of the temporary variable $1 is then passed to the rewritemap function as the lookup key, and is also passed to go.cgi as the longname parameter.

The other change I made -- to the regular-expression in the pattern -- is just a speed-up; Avoid using ".*" where possible, because it is often ambiguous and therefore requires more processing time. Rather than saying ".*", meaning "match any number of any character," and then leaving it up to subsequent processing to exclude the ".html" on the end, the expression "[^.]*" means, "match any number of any characters, up to but not including the first period you find." Therefore, this speeds up the pattern-matching a bit in this case.

Jim