I'm looking f开发者_StackOverflow中文版or 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?
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.
精彩评论