CodeIgniter Forums
Make url case insensitive - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Make url case insensitive (/showthread.php?tid=30418)



Make url case insensitive - El Forum - 05-14-2010

[eluser]aryan_[/eluser]
In my CI application I want all urls case insensitive. Here's my folder structure

application/
system/
assets/
uploads/
index.php
.htaccess

And, here's my .htaccess code:

RewriteEngine On
RewriteBase /rag
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

What to do to access all file within "uploads/" and "assets/" case-insensitive?

Thanks!


Make url case insensitive - El Forum - 05-14-2010

[eluser]mddd[/eluser]
What do you mean exactly? Do you want to rewrite a url so that /assets/js/SomeScript.js would still give you a file 'somescript.js'?
Or the other way around, so that calling /assets/js/somescript.js would give you the file named 'SomeScript.js'?

I think the first is doable; you can use RewriteMap to make your urls into lowercase.
But the second one (translating a lowercase url to match files that have capitals in them) will be more difficult!
What would happen if you have a request for /assets/js/somescript.js and there are three files in that folder: somescript.js, SomeScript.js, someScript.js.
How should the server know which file to get?

So please let us know which of the two options you are looking for.


Make url case insensitive - El Forum - 05-14-2010

[eluser]aryan_[/eluser]
[quote author="mddd" date="1273844500"]What do you mean exactly? Do you want to rewrite a url so that /assets/js/SomeScript.js would still give you a file 'somescript.js'?
Or the other way around, so that calling /assets/js/somescript.js would give you the file named 'SomeScript.js'?

I think the first is doable; you can use RewriteMap to make your urls into lowercase.
But the second one (translating a lowercase url to match files that have capitals in them) will be more difficult!
What would happen if you have a request for /assets/js/somescript.js and there are three files in that folder: somescript.js, SomeScript.js, someScript.js.
How should the server know which file to get?

So please let us know which of the two options you are looking for.[/quote]

Yes! exactly


Make url case insensitive - El Forum - 05-14-2010

[eluser]mddd[/eluser]
But which of the two do you want?


Make url case insensitive - El Forum - 05-14-2010

[eluser]aryan_[/eluser]
[quote author="mddd" date="1273846193"]But which of the two do you want?[/quote]

The first one.


Make url case insensitive - El Forum - 05-14-2010

[eluser]mddd[/eluser]
In your server configuration file, use the following rules:

RewriteMap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]

This will not work in your .htaccess file, as the rewritemap command is only availble in apache-level or host-level configuration.
Not in directory level such as .htaccess.

It basically defines a translation map 'lowercase' to use Apaches function to make things lowercase.
The rule then applies this zo any uri that has uppercase letters in it.


Make url case insensitive - El Forum - 05-14-2010

[eluser]aryan_[/eluser]
[quote author="mddd" date="1273848526"]In your server configuration file, use the following rules:

RewriteMap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]

This will not work in your .htaccess file, as the rewritemap command is only availble in apache-level or host-level configuration.
Not in directory level such as .htaccess.

It basically defines a translation map 'lowercase' to use Apaches function to make things lowercase.
The rule then applies this zo any uri that has uppercase letters in it.[/quote]

But I can't access my host config file! Any alternative?


Make url case insensitive - El Forum - 05-14-2010

[eluser]mddd[/eluser]
None that I could find when I looked.

I don't really see the problem though. Links to stuff in your assets folder are only going to come from your own site right?
just name everything lowercase and that problem is solved.

And uploads, too, are under your own control. If you name everything lowercase while saving it, there is no problem.

Can you explain what the problem is that you are trying to solve here?


Make url case insensitive - El Forum - 05-14-2010

[eluser]aryan_[/eluser]
File names are stored in DB and files are being called inside flash. File name and file name in DB doesn't match(case-issue). That's why I'm looking for this solution.


Make url case insensitive - El Forum - 05-14-2010

[eluser]mddd[/eluser]
Then you could just name the files lowercase in the DB and the problem would be gone, right?
Or you could even make the file name lowercase in Flash before loading it.