Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Show lowercase url in .htaccess with uppercase file names

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading