Possible Duplicate:
best way to handle thousands of permanent redirects

As object.

I need to do 301 redirect, for about 40.000 pages. I know that putting this quantity of lines in .htaccess maybe will slow the site, but in httpd.conf peraphs will be more faster, right ?

any advice ?

p.s. yea, it's not possible do some regex..i need about 40.000 lines of 301 :-/

  • oh yea, sorry. It's a dedicated server (not vps) with Centos.. we have only this site on this server. The site generate about 50.000 visits at month. Sep 26, 2012 at 23:32
  • i found this topic: serverfault.com/questions/414225/… seems to be very useful, i'll try !! Sep 26, 2012 at 23:50

1 Answer 1


Sounds like Apache is your web server. Since you mentioned you can't use regex, here are couple of other suggestions:

1) .htaccess

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.


2) RewriteMaps

If URLs you are redirecting from/to are too unique, to be matched by patterns, use RewriteMaps, especially DBM Hash File.

When a MapType of dbm is used, the MapSource is a filesystem path to a DBM database file containing key/value pairs to be used in the mapping. This works exactly the same way as the txt map, but is much faster, because a DBM is indexed, whereas a text file is not. This allows more rapid access to the desired key.


  • Alain Kelder: thanks !!!! i'll use probably the RewriteMaps good advice, thanks !!! i'll come back here with (hope!) good news! Sep 27, 2012 at 7:39

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