Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We need to do hundreds of 301 redirects on a site which is undergoing a massive URL restructuring. Whats the best way of doing this? at .htaccess level? at code level?, apache level? Will there be a noticeable slowdown on the site if the .htaccess becomes bloated?


share|improve this question
up vote 1 down vote accepted

mod_rewrite can use database backends using the RewriteMap directive, which probably means it can scale pretty well to a big number of redirects.

There's even a way to plug in a program to calculate redirects programatically if you want, although if you can do that, it might fit better if you do it in code.

As always, I suggest you set up a test environment and benchmark a little.

share|improve this answer
we tend to use this format for redirects - Redirect 301 /oldpage.html - which is believe is part of mod_alias not mod_rewrite. Interesting what you say though, i wasnt aware that a database backend was possible. Like you say though, it may be that benchmarking is the only way to go. Nonetheless would be interested to hear if anyone has experience of large numbers of redirects. – seengee Sep 5 '09 at 13:04
interestingly though, your mention of 301's through mod_rewrite has raised a very interesting idea. Using either RewriteMatch in mod_alias or standard mod_rewrite 301's we should be able to mass 301 redirect most pages with single rules. Cant believe this didnt occur to me before. d'oh. – seengee Sep 5 '09 at 13:09

Your Answer


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.