Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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