Search code examples
.htaccesscodeigniterlowercase

Codeigniter - client posted links with capital letters in URL


my client has printed links to the site in capital letters. I have a CI install and need to change htaccess or the base controller (I'm trying lots of options at the mo) to work like these examples (it a user types this into their address bar):

http://www.site.com/HAPPY/chappy -> http://www.site.com/happy/chappy

http://www.SITE.com/HaPpy/CHAPpy -> http://www.site.com/happy/chappy

http://WWW.Site.CoM/happy/chappY -> http://www.site.com/happy/chappy

and so on... I can't seem to get htaccess to simply say 'take everything in, turn it to lower case then process it'

is this even possible..?


Solution

  • Yes you can convert input to small letters as soon as text has been entered. You can do it with javascript. refer below code snipe for it.

    function makeLowercase() {
    document.form1.outstring.value = document.form1.instring.value.toLowerCase();
    }
    
    <input name="outstring" type="text" value="" size="30" onkeyup="makeLowercase();" onblur="makeLowercase();">
    

    OR you can use strtolower() function in PHP to covert data in to lower case and process it.