1

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?

Thanks

robjmills
  • 990
  • 9
  • 26

1 Answers1

1

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

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#RewriteMap

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.

alex
  • 1,329
  • 6
  • 9
  • we tend to use this format for redirects - Redirect 301 /oldpage.html http://www.example.com/newpage.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. – robjmills Sep 05 '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. – robjmills Sep 05 '09 at 13:09