Reputation: 115
We have a .htaccess
file and it about 8,000 lines long, about 7,800 of these lines are redirects or redirect matches. 3/4 of our htaccess redirects are Redirect 301
's and and the rest are RedirectMatch 301 ^
's. How long should a .htaccess
be before it starts to affect the performance of the website. We took all of the redirect out of the htaccess a few weeks ago and we didn't see and difference in performance. However, I think that soon the file may get too long. I usually put about a 100 redirects in a day as we have so many pages which need to be redirected.
How long should a htaccess be? and do you know any other solution for redirects?
Upvotes: 0
Views: 352
Reputation: 71931
There is no limit on how big a .htaccess
file can be, the only limit will be the limit of the file size of your OS. Or how much memory you got available on your server, because the entire file needs to be put into memory, and I believe this happens with every request made from the client (in the early days of apache
, no idea if that is still valid.. probably not.. now that i think about it :)).
Performance wise there can be a significant impact with a very big .htaccess
file (couple MBs). Because apache reads the .htaccess
file from top to bottom. Definitely for pages where it cannot find a match, because it has to go through the entire list.
An alternative to this could be to use the RewriteMap
directive and create a so called hash file in a database. This could improve performance.
Another option, which also involves a database, would be to leverage the magento redirect functionality.
I believe some benchmark tests can give you an idea what the fastest solution will be
Upvotes: 1