1

We have the following rewrite map setup in our apache config:

RewriteEngine on
RewriteMap modernmap txt:/etc/apache2/maps/salon/www.modernmap.com.txt
RewriteCond ${modernmap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+) ${modernmap:$1} [R=301,L]

The text file contains about 28,000 entries that look something like this:

/url1 http://www.example.com/url2
/url3?id=3 http://www.example.com/url9?id=33

The rewrite work for the first 24320 lines in the text file and then fail for all rewrites after line 24320. I've removed the urls at lines 24319, 24320 and 24321 just in case they were problematic and the problem persists.

I've tried it on a smaller subset and the problem just moves to a different line.

I've tried converting the text file to dbm and using the dbm and the same thing occurs.

I'm kind of at a loss on what to do next.

user3745855
  • 83
  • 1
  • 6
  • Why does your map contain query strings? `RewriteRule` does match everything after the hostname + sometimes prefix path and before the query string in their first parameter, so `/url3?id=3` will never be matched. – Sumurai8 Oct 18 '14 at 10:03

1 Answers1

1

Thanks Sumurai8. You pointed me in the right direction. We've now got this working as follows:

RewriteEngine on
RewriteMap modernmap txt:/etc/apache2/maps/salon/modernmap.txt

RewriteCond %{REQUEST_URI} ^(.+)
RewriteCond ${modernmap:%1?%{QUERY_STRING}} ^(.+)
RewriteRule ^(.+) %1? [R=301,L]

RewriteCond ${modernmap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+) ${modernmap:$1} [R=301,L]
user3745855
  • 83
  • 1
  • 6