Forum Moderators: phranque
Can anybody speculate about what might be too great a number for Apache to handle gracefully? (Obviously webservers differ too much for a one-size-fits-all answer, but if you have any experience, I'd be happy to hear it...)
-- b
If you have to redirect each one individually, the answer is probably much less. It really depends on the situation, how many URLs you can match based on 'non-catch all' patterns and some of it will depend on your ability to construct efficient regular expressions. I've redirected over 11,000 pages in less than 10 rules before and not noticed any significant load on the server, but I would not put 11,000 rule in a single file.
For the one-URL-at-a-time rules, consider putting them into either individual <Directory> containers in the server config file, or into individual .htaccess files in the specific directories to which they apply; requests to other directories then won't even 'see' these rules.
However, you must be and remain aware of a very important factor: Rules will be processed from 'the top down' -- from the server config files down through each .htaccess file along the filepath to the content to be served. It is critical that *all* external redirects which might potentially apply to a URL be processed before *any* internal rewriting of that URL can take place. If this rule is broken, then an external redirect will 'expose' an internally-rewritten filepath as a URL, and you will have major headaches with search engines as a result. So plan carefully...
As for how many is too many, it's like asking "How long is a piece of string?" The answer depends on your server's raw performance, the number of 'hits' you get, how efficient your redirect code is, and where it is located... As a result, it's quite difficult to even guess the number of directives you might be able to execute without any noticeable performance degradation; Suffice to say that the answer is likely greater than 100 but less than 3000.
However, there's no fundamental difference between Apache module directives parsed in .htaccess files and PHP scripts parsed in the content-handler phase, and many sites have PHP scripts with thousands of lines of PHP code... Just make your code as efficient as humanly possible and hope for the best.
Jim