The way you've got this written, you'll never get to your second rule. There is no way in the regex directly to tell you if there was a mapfile match.
There might be a way to do it with the rewrite API, but I'm not really familiar with it. What I would do is change the URL for the offers to something other than /books/ You could simply add something static like /books/offers/ which would allow you to specify additional static text in your regex, or you could change it altogether to something like /offers/ HTH --Ben Doom cf coder wrote: > Hello everybody, > > I'm struggling to get my rewrite rule to work. I would appreciate any help I > can get. > > I'll try to explain as best as I can. > > I want a RewriteRule that can do the following: > > I have a rule that translates: > > http://mysite/index.cfm?offers.books&bookid=1 > > to: > > http://mysite/offers/books/Harry-Potter > > I have a mapfile.txt file in helicon my rewriteengine. > > And a rule that does this is: > RewriteRule /offers(/books/.*) > /index.cfm?go=offers.details&bookid=${mapfile:$1} > > The mapfile.txt file contains the "book keyword url" and "bookid", > ex: /books/Harry-Potter 1 > > and a rule that translates: http://mysite/index.cfm?go=books.all > > to: > > http://mysite/offers/books/all > > And the rule that does this is: > RewriteRule /offers/books/([a-zA-Z0-9.-]+)(.*) /index.cfm?go=offers\.$1 [PT] > > Here's the problem: When I try to browse this page: > "http://mysite/offers/books/all" the browser gets confused because the > regular expression pattern for both the rules have the same pattern i.e > "/offers/books/". I hope this is making sense. I want to change my rule which > works in both the cases. > > Rules: > > RewriteRule /offers/books/([a-zA-Z0-9.-]+)(.*) /index.cfm?go=offers\.$1 [PT] > RewriteRule /offers(/books/.*) > /index.cfm?go=offers.details&bookid=${mapfile:$1} > > I can browse this page (it's working): http://mysite/offers/books/all > > but when I try to browse this page: http://mysite/offers/books/Harry-Potter > > I get an error which states: This is the template > "../fuseboxShared/ErrorTemplates/fusebox.undefinedFuseaction.cfm" An Error of > type "fusebox.undefinedFuseaction" has occurred undefined Fuseaction You > specified a Fuseaction of Harry-Potter which is not defined in Circuit books. > > This is what I have in the httpd.conf file: > > RewriteEngine on > RewriteMap mapfile txt:mapfile.txt > > RewriteRule /offers/books/([a-zA-Z0-9.-]+)(.*) /index.cfm?go=offers\.$1 > RewriteRule /offers(/books/.*) > /index.cfm?go=offers.details&bookid=${mapfile:$1} > > The first rule is getting executed when I try to browse: > http://mysite/offers/books/Harry-Potter > > It errors because the text "/offers/books/" is in both the rules but only > want the first rule to execute when the "bookid" doesn't exist in the url. > > Any ideas to get around this problem? > > > Thanks in advance. > > Regards, > > cfcoder > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1122 Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21
