1 # Blosxom Plugin: redirect
2 # Author: Fletcher T. Penney (http://fletcher.freeshell.org)
8 # --- Configurable variables ---
10 # Where is the redirect file?
11 $redirect_file = "$blosxom::plugin_state_dir/redirect";
13 # ------------------------------
15 $path = $blosxom::path_info;
18 warn "Flavour check $blosxom::flavour\n";
19 if (open (REDIRECT, "< $redirect_file")) {
20 while ( $line = <REDIRECT> ) {
21 if ($line =~ /(.*)=>(.*)/) {
24 if ( $path =~ s/^$old/$new/ ) {
38 # We only end up here if we are redirecting this url
40 $message = qq!This page has been moved. The new URL is <a href="$blosxom::url/$path">$blosxom::url/$path</a>.\n!;
42 $blosxom::output = $message;
43 print "Status: 301\n";
44 print "Location: $blosxom::url/$path\n";
55 Blosxom Plug-in: redirect
59 One problem with having a weblog is that you become somewhat committed to your URL structure. If you decide to rearrange your site, you run the risk of breaking external links. The autocorrect plugin helps, attempting to find a story that might have moved.
61 The difficulty with this is that the url's don't really get fixed.
63 I recently moved my site out of the "/weblog" directory by improving my .htaccess file. I like the url's better, but I have lots of links out there that still point to the "/weblog" hierarchy. I came up with some ways of pointing this out to human viewers, but robots still travel the old hierarchy, and it's a pain for people to figure out where to go.
65 This plugin allows you to set up a redirect file that consists of lines like the following:
66 path/to/some/article=>new/path/to/article
68 If someone tries to go to a non-existent directory, you can re-route them automatically to the new location, and the url is updated in their browser. For instance, my redirect file looks like this:
71 Basically it strips out the weblog directory, creating a URL that is now valid.
78 =head2 VERSION HISTORY
80 0.1 - initial public release
84 None known; please send bug reports and feedback to the Blosxom
85 development mailing list <blosxom-devel@lists.sourceforge.net>.
89 Fletcher T. Penney, http://fletcher.freeshell.org
91 This plugin is now maintained by the Blosxom Sourceforge Team,
92 <blosxom-devel@lists.sourceforge.net>.
96 Blosxom Redirect Plug-in
97 Copyright 2003, by Fletcher T. Penney
99 Permission is hereby granted, free of charge, to any person obtaining a
100 copy of this software and associated documentation files (the "Software"),
101 to deal in the Software without restriction, including without limitation
102 the rights to use, copy, modify, merge, publish, distribute, sublicense,
103 and/or sell copies of the Software, and to permit persons to whom the
104 Software is furnished to do so, subject to the following conditions:
106 The above copyright notice and this permission notice shall be included
107 in all copies or substantial portions of the Software.
109 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
112 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
113 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
114 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
115 OTHER DEALINGS IN THE SOFTWARE.