I’m writing a url shortener which uses lowercase and uppercase characters.
I’ve written an intermediate script that helps me with analytics. This is in the .htaccess:
RewriteCond %{HTTP_HOST} q.(.{5})\.example.com
RewriteRule (.*) http://www.example.com/this/r/%1
(url’s changed ofcourse)
But somehow if the user navigates to q.Fbbbc.example.com he ends up at http://www.example.com/this/fbbbc (with lowercase F)
Any idea as how to fix this? A few clients of mine are already experiencing problems and I didn’t think this rule would convert to lowercase..
As a related issue: In the frontend I use a basic <a href="http://q.Fbbbc.dim.io">click</a> to have users test the functionality, but in Google Chrome a hover over this link shows a lowercase url. The code in chrome really does show an uppercase F though… Any thoughts?
You might want to read the RFC 3986 – Uniform Resource Identifier (URI): Generic Syntax. Specifically Section 3.2.2. – Host. You’ll come across the following statement:
The host subcomponent is case-insensitive.In short:
'AA.ExAmPlE.Org' === 'aa.example.org'. Lower-Case being the dictated normalized form. If upper-case hostnames reach your script depends (at least) on (a) the browser, (b) intermediate proxies, (c) the http server. At least two components you have absolutely no control over.If you want to make use of case-sensitivity, you’ll have to move your slug (
Fbbbc) to the pathname:http://q.example.org/Fbbbc.