Relative efficiency of replacing rewrite rules with rewriteMaps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-urla
RewriteCond ${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 the
rewrite 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

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux