Bizarre error using rewritemap

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Bizarre error using rewritemap

09 Jan 2013, 08:04

I'm trying to do part of my task using a rewritemap.

I have a bunch of existing pages, all of which contain enquiry- or quote- or quotes- as part of the URL.

So I created a rewrite map list of old-url new-url pairs.

I then have the following directives:

RewriteMap enquiry txt:d:/website/enquiry.map
RewriteRule (.*[enquiry-|quote-|quotes-].*\.html) $(enquiry:$1:mqh/Custom404.html&oqs=$1) [L]

As expected, if I put in made-up-enquiry-c999.html, it goes to the custom404 service and says (correctly) that "made-up-enquiry-c999.html" was not found.

However, it's also matching things that don't seem to fit the pattern, such as fireworks-c29.html and sending them to the 404 as well.

If I add R=301 to the options, it also seems to get into a loop, telling me there's a redirect loop.

I can't understand how it's triggering on something that, on the face of it, shouldn't match.

I've had to remove this rule as it's stopping perfectly good links from working - links that are in fact static files.

Am I best having a RewriteCond at the top of my list to serve any URLs that map to a file?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Bizarre error using rewritemap

09 Jan 2013, 08:11

I think what you're looking for is in FAQ

This condition will check if there's a matching entry in your mapfile, if not - nothing happens:

Code: Select all
RewriteCond ${mapfile:$1|NOT_FOUND} !NOT_FOUND


Regards
Andrew

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: Bizarre error using rewritemap

09 Jan 2013, 13:02

I did see that, but I couldn't parse the syntax to work out what it was doing!

Does it essentially just set a true/false flag?

Also, this section:

3. Applying map file only if specific pattern is matched

Please add the following condition before the rule dealing with map file to accomplish this:
Code:
RewriteMap mymap txt:map.txt
RewriteMap mylower int:tolower
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$
RewriteCond ${mymap:${mylower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? ${mymap:${mylower:%1}} [NC,L]


Does that mean that the rewriterule is *not* fully validated before calling the map?

That would explain what the problem might be.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Bizarre error using rewritemap

10 Jan 2013, 16:43

My suess is that the condition RewriteCond %{REQUEST_URI} ^/([^/]+)/?$ doesn't match the querystring. the pattern looks strange.
give an example of the request, pls.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 44 guests