I have a problem with a website on a server that is set to destinguish between URLs or files with capitals in them and the same ones without capitals. For example, the two URLs below are clearly the same (there really is only one file on that location, I've checked that), but are regarded as two different URLs: http://www.MyDomain.com/File.HTML http://www.mydomain.com/file.html Code (markup): How do I set the server so that it understands that both versions are the same and to automatically "redirect" (?) all URLs or files with capitals in them to the non-capitalised URLs or files? Cheers for your help!
It seems that your domain is hosted on Linux server. Please note that Linux is case sensitive hence file.htm and File.HTM will consider as two different file. Kailash
It would be nice and useful if you'd tell me what to look for, instead of just telling me to change the .htaccess file.
deadlychaos25 is right. Setting it up in .htaccess would be an easy fix. Put the following in your .htaccess file. RewriteEngine on RewriteRule ^file.html$ /file.html [NC,L] What is does is rewrite any upper- and/or lowercased version of file.html to file.html. The NC in the [NC,L] part means case insensitive. Another option would be to enable mod_spelling on your server, but that is not really a good idea.
Mange tak, Morten. I'll add that to my .htaccess file. The problem with the URL rewrite is that it will only work for the file types that I include in the mod_rewrite. Given that there are a few hundred files on the Apache server with various file extensions, there is a reasonable chance that I forget to include one or more. Is there perhaps a way to include all the files of all the file extensions using one or only a few lines of code?
Hi, Unfortunately, this cannot be properly dealt with using mod_rewrite. You are better off checking to see if your provider allows mod_speling. Please note that the domain is not case-sensitive only the path is. I highly recommend to all our clients to adopt a naming structure that does not use upper-case letters, spaces, and other characters that must be escaped on a Unix variant file system.
As JPC-NickO writes, this is not really something that should be dealt with in .htaccess for a large number of files. mod_spelling on the other hand isn't much better and is in this case really just a cure for a problem that shouldn't have existed in the first place. The best solution would be to make sure all your files are lowercased. I know this isn't the answer you wanted to hear but I really don't have another one for you
Well, you could set up a rewritemap, but that would still require you to have an updated map of all your files with the exact capitalization and if you are going to do that, then you might as well just rename all the files to their lowercased versions.
Let me know if you do decide to lowercase all of them. I have a nice little shellscript that will do it for you.
Cheers for the offer, Morten, but after some consideration I've concluded that it would cost me too much time and effort. And the website I am working on is just not worth it. Thanks again for your help.