Bizarre error using rewritemap
4 posts
• Page 1 of 1
Bizarre error using rewritemap
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?
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?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Bizarre error using rewritemap
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:
Regards
Andrew
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
Re: Bizarre error using rewritemap
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:
Does that mean that the rewriterule is *not* fully validated before calling the map?
That would explain what the problem might be.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Bizarre error using rewritemap
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.
give an example of the request, pls.
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 44 guests