My URL’s look like this: mysite/People/George_A_Custer
I want to change everything to lower case and replace the underscores with dashes, like this:
mysite/people/george-a-custer
I’m also thinking of modifying my scripts so that URL’s with spaces or %20 instead of dashes will default to the URL’s stored in my database (e.g. george-a-custer). Of course, I want visitors to be forwarded from old URL’s to my new URL’s. Also, I’d like to avoid confusing statistics that show the number of hits for endless variations of the same URL.
From this SitePoint thread:
“In terms of making sure that your hits track each page correctly in aggregate, the best way to do that is to set redirect rules in .htaccess to force the URL to lower case. Then even if your filenames are not case sensitive, you will get all the hits counted against the lower case format.”
So I’d like to ask if anyone can tell me how to modify the following .htaccess file if I want to go with lower case URL’s. I assume I need to change Community, Genres and Music to community, genres and music. But what about [a-zA-Z0-9()/-] ? Would I change it to [a-z0-9()/-] ?
Is there anything else I need to do to “force the URL to lower case”? Thanks!
RewriteEngine On
RewriteRule ^test\\.htm$ test.php [L]
Options -MultiViews
# php_value magic_quotes_gpc 0
php_flag magic_quotes_gpc Off
RewriteRule ^Topics/([a-zA-Z0-9()_/-]+)/?$ Topics/index.php?topic=$1 [L]
RewriteRule ^World/([a-zA-Z0-9()_/-]+)/?$ World/index.php?area=$1 [L]
RewriteRule ^Community/([a-zA-Z0-9()_/-]+)/?$ Community/index.php?community=$1 [L]