Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to move dozens of static websites (plain html) from Windows/IIS to Linux/Apache. As you may know, Linux is case-sensitive and I'm pretty sure there may be hundreds of html files with file references in one case and the referenced file in another case :(

Is there a tool that will check/fix this (by fixing the reference or renaming the files on the filesystem)?

Thanks! JFA

share|improve this question
    
Thanks all for the answers. I'm going to rename all files to lower-case and I'm going to use mod_rewrite (which I had no idea existed). Thanks again! I Love ServerFault! –  JFA Oct 7 '09 at 15:24
add comment

5 Answers

up vote 1 down vote accepted

You may want to investigate simply enabling mod_speling. It can handle most of the case issues for you. If having the correct case isn't that important to you you could just enable this and move on.

share|improve this answer
    
Hey Zoredache thanks for the mod_speling tip! This is what I finally used as mod_rewrite was working properly but what if some remote users still upload stuff with case inconsistencies...(I'd have to then modify files to lower-case and so on...) This mod_speling is just what the doctor ordered! Thanks! It works beautifully! –  JFA Oct 7 '09 at 22:51
    
If you feel this or another answer is the best you should consider accepting it. –  Zoredache Oct 7 '09 at 23:30
add comment

Renaming the file to lower case isn't enough, because inbound links or bookmarks that have uppers are going to get "404 - file not found" errors. Rename the files, then use mod_rewrite to force urls to lower:

http://www.chrisabernethy.com/force-lower-case-urls-with-mod%5Frewrite/

share|improve this answer
add comment

As far as I know there isn't a tool specifically designed to do this, however, if you want to delve into Linux a little bit, I would suggest creating a script using awk, sed and possibly grep to search for and replace all of the incorrect entries. However, this method might still take a while especially if you don't have much experience with the command line or shell scripting.

Alternatively, I believe IDEs such as Dreamweaver and whatnot have the ability to rename a file and update all of the references, so you may look into that. It means that you would have to do it for every file, but it might still be faster than trying to write a script that would catch all possible cases. Aptana is another IDE that might do this, although I have not used it for said purpose.

share|improve this answer
add comment

I would just use a shell script, perl, or the rename command to rename them all to lower case. This stackoverflow post has a bunch of different methods including shell and perl, but actually, most of those will break if spaces...

I would do the following with zsh, although not the fastest option probably:

for file in **/*.html; do 
    if [[ "$file" != "${(L)file}" ]]; then
        mv "$file" "${(L)file}"; 
    fi
done
share|improve this answer
    
Actually, most of those will break if spaces in the file name...sigh... –  Kyle Brandt Oct 6 '09 at 19:51
add comment

You could serve your websites from a partition mounted in linux with filename translation set to case insensitive.

If you use a vfat (fat32) filesystem on linux you can mount it as follows

$ mount -t vfat /dev/XXX /var/windows/websites

Any filename inside /var/windows/websites will be treated the same way as windows does.

share|improve this answer
    
Thanks for this tip. I had no idea about this. Anyway, I think I'm going to try the other methods as I plan to usePOSIX ACL's and enable quotas on ext3. –  JFA Oct 7 '09 at 15:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.