Forum Moderators: phranque
www.example.com/bn/products/product-details/21 www.example.com/bn/products/product-details/MC622 RewriteRule ^bn/products/product-detail/21$ http://www.example.com/bn/products/product-detail/MC622 [R=301] [R=301]
Is having 500+ rewriterules in the htaccess file OK?
RewriteRule ^bn/products/product-detail/ /example.com/fixup.php [L]
where "fixup.php" is a little script that contains the names of all your old URLs and their new targets. The script performs the lookup and issues the redirect--or issues a 404 if it can't find a rule for the requested URL. (You could optionally capture the request and attach it to the php as a query, but it shouldn't make any difference, since php can find the Request-URI unaided.) Note that even though the RewriteRule itself has only an [L] flag, it needs to be located among other RewriteRules that create redirects. I have found that in order for these rewriterules to work, they must be placed above all other rewriterules.
first group your rules in order of severity
You mean like
would there be any advantage to using your alternate method?
How long should these redirects be kept in the htaccess file.Forever. The rate of requests will soon drop off, but they never stop entirely. This applies both to 301 and to 410 responses.
At some point, I would imagine, the search engines will update all links. Any idea how long that might take? A month, a year, a decade?It depends on how popular the page is--anywhere from hours to months.
Do spiders look at an htaccess file, or is it invisible to them until a redirect sends the 301?Nobody sees the actual htaccess file. (Try it. Request example.com/.htaccess at, ahem, your own site. If you do not get a 403 response you have the world's worst host and should change right away.) Each request passes through the htaccess file, which analyzes the request and makes any needed changes, up to and including issuing redirects.
Do spiders look at an htaccess file, or is it invisible to them until a redirect sends the 301? If spiders do not "see" the htaccess file, I would think that the redirects would need to be in a long time as some products may be much less popular than others.
Nobody sees the actual htaccess file.