Forum Moderators: phranque

Message Too Old, No Replies

Making URL's Lowercase

         

DuckTapeCoder1

4:50 pm on Feb 5, 2009 (gmt 0)

10+ Year Member



Is there a way Mod Rewrote to force all URL's to be lowercase?

Let's say someone types in www.example.com/Best_Shoe_Deal.php

I would like to rewite to www.example.com/best_shoe_deal.php

Thanks!

[edited by: eelixduppy at 6:28 am (utc) on Feb. 6, 2009]
[edit reason] exemplified [/edit]

g1smd

4:58 pm on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You should not rewrite that URL request. An internal rewrite would mean that both URLs will return identical content, both with a "200 OK" status. That's not a good idea.

You should instead redirect that request to the canonical format of your choosing. All lower case is usually the best way to have your URLs. Use a 301 redirect.

You can use a RewriteMap, and your host will need to define that in httpd.conf for you, and activate it, if you don't have access to do it yourself.

The links within your site should use the format that you want users to see. Links 'define' URLs.

There are several recent and current threads with {tolower} examples within that can get you started.

jdMorgan

5:47 pm on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See this thread [webmasterworld.com] in our Apache Forum Library [webmasterworld.com] for a possible .htaccess solution if you do not have the server-configuration-level access required to define a RewriteMap.

Warning: The code is complex, and must be considered as a whole; You cannot just take one snippet out of the middle and expect it to work. It is an "advanced topic" and not for the faint of heart or those not completely confident in their mod_rewrite interpretation and implementation skills; Otherwise, it will likely require more "support" than this forum can supply...

Jim