At Wed, 22 Jun 2005 16:33:53 +1000, Simon Bryan wrote: > I have uploaded a web based CD to our Moodle setup, but all the links > are broken. In true sloppy MS style most of the filenames are in > uppercase whereas the html files refer to them in lower case. The > underlying webserver is Apache, (thought mod-speling might help from > some reading but it is already installed). I am looking for the lazy way > out of going through and editing all the links in the html files or > renaming all the disc files, is there a solution? NB there are hundreds > of files and corresponding links :-(
Totally untested (other than checking it compiles). Install and load mod_perl, then put this file in /usr/share/perl5/Apache/IgnoreCase.pm (or wherever other Apache/foo.pm modules are on your distro), then put something like this in your httpd.conf (a <Location> block would be fine too): <Directory /path/to/my/web/based/cd> PerlFixupHandler Apache::IgnoreCase </Directory> (How do you people use Apache without mod_perl?)
package Apache::IgnoreCase; use Apache::Constants ':common'; use strict; use warnings; sub find_path { my $path = $_[0]; my $new = ''; COMPONENT: for my $component (split '/', $path) { next if $component eq ''; my $tmp = "$new/$component"; if (-e $tmp) { $new = $tmp; } else { my ($dir, $entry); opendir $dir, $new or return undef; while (defined($entry = readdir $dir)) { if (lc($entry) eq lc($component)) { $new .= "/$entry"; next COMPONENT; } } return undef; # similar entry not found } } $new = '/' if $new eq ''; # corner case return $new; } sub handler { my $r = $_[0]; my $fn = $r->filename; unless (-e $fn) { my $new = find_path($fn); $r->filename($new) if $new; } return OK; } 1;
-- - Gus
-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html