< Day Day Up > |
Recipe 22.7. Redirecting URLs to a New Directory22.7.1 ProblemYou've just given your web site a massive overhaul. It was a cluttered, disorganized mess, so you rebuilt it from the ground up. But now all the links are different, so all those bookmarks visitors have made to your pages, and all those links in online articles and search engines are useless. What can you do about it? 22.7.2 SolutionAdd Rewrite directives to httpd.conf. This example redirects the old URLs to the new ones: RewriteEngine on RewriteRule ^/olddir/(.*)$ /newdir/$1 In plain English, this means that http://www.bratgrrl.com/olddir/, and every file and directory that follow olddir/, will be redirected to http://www.bratgrrl.com/newdir/. 22.7.3 DiscussionThis is a good basic Rewrite rule that takes care of one of the most common redirection needs. As you can see, if you're moving entire directories at a time, it's fairly simple. If you have bales of individual files going to different locations, you have a lot of rules to write. 22.7.4 See Also
|
< Day Day Up > |