Handling url letter case

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
jayashree
Forum Newbie
Posts: 6
Joined: Fri Mar 06, 2009 5:44 am

Handling url letter case

Post by jayashree »

I need to write the script to handle the url letter case.

My requirement is, what ever be the original case(uppper,lower,proper) I need to resolve it to lowercase url. Can I get the script for doing the same with htaccess.php ?

Thanks
Jayashree
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Handling url letter case

Post by kaisellgren »

Sorry, I did not understand.

Your website will load fine whether it is YOURSITE.COM or yoursite.com.

If you are talking about $_GET (e.g. site.com/file.php?data=SoMeDaTa) then you can force the case to be lowercase with strtolower($_GET['data']) or to uppercase with strtoupper(), but I did not understand what you wanted...
jayashree
Forum Newbie
Posts: 6
Joined: Fri Mar 06, 2009 5:44 am

Re: Handling url letter case

Post by jayashree »

kaisellgren wrote:Sorry, I did not understand.

Your website will load fine whether it is YOURSITE.COM or yoursite.com.

If you are talking about $_GET (e.g. site.com/file.php?data=SoMeDaTa) then you can force the case to be lowercase with strtolower($_GET['data']) or to uppercase with strtoupper(), but I did not understand what you wanted...
Thanks for your reply. The problem I am facing is I ma not able to resolve
yoursite.com/Welcome.php to yoursite.com/welcome.php. I tried


# Skip this entire section if no uppercase letters in requested URL
RewriteRule ![A-Z] - [S=28]
# Else rewrite one of each uppercase letter to lowercase
RewriteRule ^([^A]*)A(.*)$ /$1a$2
RewriteRule ^([^B]*)B(.*)$ /$1b$2
RewriteRule ^([^C]*)C(.*)$ /$1c$2
...
RewriteRule ^([^Z]*)Z(.*)$ /$1z$2
# If more uppercase letters remain, re-invoke .htaccess and start over
RewriteRule [A-Z] - [N]
# Else do a 301 redirect to the all-lowercase URL
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

in my .htaccess file. It converts yoursite.com/Welcome.php to yoursite.com///welcome.php
but I am getting server error. Can you help me in fixing this...
Post Reply