问题原文
原帖链接 · Nicholas Pavlinsky · CC BY-SA 4.0
I am migrating all the data from an old Windows FTP server to a Linux environment, and have run into some issues.
The people who were previously uploading files (usually simple html files and images) were following the very poor practice of capitalizing some characters in the folder and file names, then entering the filenames with incorrect case in their html code. They have also been sending out hyperlinks to those files in all lowercase. Since the server was windows, and case-insensitive, it was simply forgiving this and everything would function fine regardless.
Now that the files have migrated to a case-sensitive file system. These hyperlinks are broken, and the improperly coded HTML files will not work.
I have been toying with several solutions. Right now my plan is to use an .htaccess to make all requests case insensitive, but I wanted to make sure I am thinking of any adverse effects this might have. I know it could have a serious effect on dynamically generated pages or links, but since this is just a simple staging server, and we only use it to show sample files, we aren't going to be doing any of that anyway.
Would this also effect href tags in html code? Are there some other serious consequences of this that I may not be thinking of?
I just wanted to get a few other opinions and options together. Is there a better way to tackle this issue?
Thanks guys!
已采纳解答
原帖链接 · HBruijn · CC BY-SA 4.0
I have had pretty good luck with the spelling correction provided by Apache's mod_speling which has the advantage that you don't have to modify the existing file/directory names, nor the existing HTML code, but your mileage may vary:
It does its work by comparing each document name in the requested directory against the requested document name without regard to case, and (optionally) allowing up to one misspelling (character insertion / omission / transposition or wrong character). A list is built with all document names which were matched using this strategy.
If, after scanning the directory,
- no matching document was found, Apache will proceed as usual and return a "document not found" error.
- only one document is found that "almost" matches the request, then it is returned in the form of a redirection response.
- more than one document with a close match was found, then the list of the matches is returned to the client, and the client can select the correct candidate.
Enable by setting:
CheckSpelling On
in your httpd.conf in a VirtualHost and/or Directory block (or even a .htaccess file).
You can limit the spelling correction to lower/upper case changes only with:
CheckCaseOnly On
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
