views:

54

answers:

2

I'm looking for a way, preferably with .htaccess to rewrite a url when a user types in something with a capital.

For example, the url could be website.com/pagename

and the usertypes in website.com/PageName or website.com/PAGENAME

Whats the best way to do with without slowing down page load?

+2  A: 

You can either do an HTTP redirect (via Apache):

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]

or do the processing in PHP:

$_SERVER['REQUEST_URI']=strtolower($_SERVER['REQUEST_URI']);

HTTP redirection isn't really as efficient as the PHP solution.

stillstanding
+1: I hadn't come across RewriteMap before.
Chris
A: 

you can use sites to generate small urls such as tinyurl , goo.gl etc.

[spam removed]

Anupam Tamrakar
That's not really what OP is looking for.
Chris