Welcome Guest, Not a member yet? Register   Sign In
Make url case insensitive
#1

[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!
#2

[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.
#3

[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
#4

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

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

The first one.
#6

[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.
#7

[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?
#8

[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?
#9

[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.
#10

[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.




Theme © iAndrew 2016 - Forum software by © MyBB