Redirect http requests to a new folder with apache rewrite rules
When you reorganize the structure of a website, you might want to redirect requests to files in a old folder to a new one without loosing the pagerank. In this example, I will redirect all requests from directory "olddir" to directory "newdir", so that requests like http://www.yourdomain.tld/olddir/page.htm get redirected to http://www.yourdomain.tld/newdir/page.htm without loosing the Google pagerank of the pages.
The following rewrite rules can be added into a .htaccess file in the website directory or in the vhost configuration.
RewriteRule ^olddir/(.*)$ newdir/$1 [R=301,L]
This rewrite rule redirects automatically all requests to pages or subdirectorys of "olddir" to the same page or subdirectory in "newdir".