How many rewrite rules should I expect to manage? [closed]

I'm dealing with a hosting team that is fairly skittish of managing many rewrite rules. What are your experiences with the number of rules your sites are currently managing?

I can see dozens (if not more) coming up as the site grows and contracts and need to set expectations that this isn't out of the norm.

Thanks


Solution 1:

Are they concerned about the logistics of managing many rules, or the performance?

In the former case, consider combining a hashmap generated from a DB, managed by either your CMS or a CRUD tool if, like Alex, most of your rules actually come from things like content moves and marketing campaigns. They can be tested by your content people and then migrated into production with little effort for your server teams.

If the problems is performance, well, that's a "how long is a piece of string" question, but I've certainly worked on sites with literally hundreds of rewrite rules to support things like content migrations where there's been no measurable impact on the response times for the servers.

Solution 2:

You could consider using http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap which would allow a single rule read from a hashfile.

Solution 3:

We recently had a practical experience about this. See my answer here: https://stackoverflow.com/questions/1364673/apache-redirects-rewrite-maximum/18120886#18120886

I had the very same question recently. As I found no practical answer, we implemented an htaccess 6 rules of which 3 had 200,000 conditions.
That means an htaccess file with the size of 150 MB. It was actually fine for half a day, when noone was using this particular website, even though page load times were in the seconds. However next day, our whole server got hammered, with loads well above 400. (machine is 8 cores, 16 GB RAM, SAS RAID5, so no problem with resources usually)

I suggest if you need to implement anything like this. Design your rules, so they don't need conditions, and put them in a dbm rewrite map. this easily solved the performance issues for us.

http://httpd.apache.org/docs/current/rewrite/rewritemap.html#dbm