Welcome Guest, Not a member yet? Register   Sign In
URI Segment Case Sensitivity
#1

[eluser]Unknown[/eluser]
I've seen some posts on this in the past but they all seem to be unresolved or at least unclear to me whether it is expected behaviour or not.

I am using CI 1.7.1. Clean URLs are good for SEO, duplicate URLs are not.

For example:

http://<domain>/<controller>/<method> will return 200 no matter what the case of <method> may be.

e.g., http://mydomain.com/mycontroller/mymethod, http://mydomain.com/mycontroller/Mymethod, http://mydomain.com/mycontroller/MyMeThOd all work.

I see in CodeIgniter.php on line 225 the following:

Code:
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))

Seems like the method is always compared in lowercase. Ideally I would like to be able to specify in a configuration that I want all lowercase URLs and any other matches that only differ by case should 301 redirect to the lowercase form of that URL.

Seems like there is no harm in removing the first strtolower call so long as I am expecting lowercase. But I don't like hacking core code because it makes updating more difficult. Is there any better solution or configuration option I am missing?




Theme © iAndrew 2016 - Forum software by © MyBB