I am aware that having too many redirects in a .htaccess file can lead to a loss of performance in apache, this leads me to my question is there a faster way to configure redirects in apache particularly if i have several hundred? i am also having to use a cpanel server in this instance.


Can you put them into httpd.conf instead of a .htaccess file? At least this way, apache only has to parse them once.

Alternatively, look at Apache's RewriteMap directive in the mod_rewrite module. To quote:

For plain text and DBM format files the looked-up keys are cached in-core until the mtime of the mapfile changes or the server does a restart. This way you can have map-functions in rules which are used for every request. This is no problem, because the external lookup only happens once!

In the grand scheme of things, 'several hundred' isn't a lot - I've known .htaccess files to have several thousand redirects - not necessarily wise, but not impossible.

  • thanks for the comments, am using cpanel so i know it effectively overwrites your httpd.conf everytime there is a change of that nature, i have heard of using include files so as to save the changes, just unsure of where they go and what format/filename – anthonysomerset Mar 13 '11 at 16:24
  • Have a look at the documentation here – Ian Gregory Mar 13 '11 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.