0

In my .htaccess file, I have this code:

RewriteMap tolowercase int:tolower 
RewriteRule ^(.*)$ ${tolowercase:$1} [R=301,L]

From: htaccess Uppercase URL to lowercase

This change the url from uppercase to lowercase and works fine for me.

All I want now is that I can keep my filenames in uppercase, but my server opens the files (with capitals in the names) and shows a url without capitals.

I searched for a solution via the internet and this platform, among others, but I ended up on pages that explain how you can convert a url to a url without capital letters. Now I want this too, but he has to open the files with capital letters in the file name.

SoftDev
  • 7
  • 1
  • 5
  • _Aside:_ The directives as posted would only work in a _server_ (or _virtualhost_) context, not `.htaccess` as stated. – MrWhite Jan 06 '22 at 12:29

1 Answers1

1

So basically you want to open URL without capital letters and so it would work with capital letter filenames? Logically it's impossible. File names in most of operating systems are case sensitive. When you ask for text.txt, it could refer to Text.txt or TEXT.txt or TEXT.TXT or text.TXT or different combinations... how the server would decide which one? Logically the thing that you are trying to do doesn't make any sense and won't work. URL rewriting is not only about what is being shown in URL bar, it affects the request itself.

The solution would be to change the URL in address bar with JavaScript (after processing the request by server), but then imagine that a person would want to refresh the site - would wrap up to the same problem as above.

Flash Thunder
  • 11,672
  • 8
  • 47
  • 91
  • "File names in most of operating systems are case sensitive", except... Windows. So, another solution would be to switch to a Windows server! – MrWhite Jan 06 '22 at 12:31
  • @MrWhite Yep, true, but that comes with a whole bunch of disadvantages, which should also be mentioned. – arkascha Jan 06 '22 at 14:48