httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Beckett <paul_beck...@outlook.com>
Subject [users@httpd] Relative efficiency of replacing rewrite rules with rewriteMaps
Date Fri, 20 Sep 2013 13:11:22 GMT
I would like to try and reduce the number of rewrite rules I have (from 5000) to a much smaller
number of rewrite maps. My main goals in doing this are to improve site performance, and make
configuration more manageable.I need to be able to handle the following cases:/dir1/link1
   -> /dir1/other1/dir1/link2    -> /dir1/random2/dir1/link3    -> /dir1/link3  
 [no change, and I don't know all the possible URL's]/dir2/link4    -> /dir3/link5
The best I've been able to come up with in the Apache config is:
RewriteMap  map-urla               txt:/path/to/map-urlaRewriteCond ${map-urla:$1}       
 >""                   [NC]RewriteRule ^/dir1/map-urla(.*)$   /dir1/${map-urla:$1}  [R]
This works in terms of getting URL's to the write place, but before I expend a colossal amount
of effort rewriting over 5000 lines of config, I'm hoping to clarify that this will actually
provide a performance benefit.In particular, will it only evaluate the /dir1/ path once, and
skip over this for other urls (eg. /dir2/) or will the rewriteCond be evaluated first going
through every line in the rewritemap prior to evaluating the /dir1?

Background:I've just inherited an apache server with about 5000 RewriteRules! The majority
of which are currently being evaluated for nearly every request, which I can't imagine is
going to be good for performance.A lot of the rewrites are a result of the site owner wishing
to ensure original URL's continue to work after the site was restrucutred  (due to external
links and associated SEO value of those links).Because page names have been changed, this
was done as individual rewrite rules for enormouse numbers of pages.
My initial thoughts were that a rewrite map would be much more efficient. However, because
in quite a few cases, it's only the page names that have changed and not the directory name,
I'm not sure if this will be more efficient, due to my having to add a RewriteCond to ensure
that therewrite rule doesn't create a circular redirect / failure for the new pages (the names
of which I often don't know).
Any advice on how this will be evaulated, it's relative efficiency or any better approaches
would be greatly appreciated.
Thanks,Paul 		 	   		  
Mime
View raw message