[Last Call] Learn how to a build a cloud-first strategyRegister Now


mod_rewrite force to lower case

Posted on 2009-02-23
Medium Priority
Last Modified: 2012-05-06
I dont believe this is possible, just asking for confirmation.  But if I want to make sure that all extensions, page names or folder names are all lower case that without listing each one out individually I cannot do it through Mod_Rewrite.  Is that true?
Question by:iceman19330
LVL 29

Expert Comment

ID: 23714895

do you meant url case change ??? like all lower case

have a look this 2 , if you meant something like this


LVL 27

Accepted Solution

caterham_www earned 2000 total points
ID: 23714961
If you can use the rules in your httpd.conf instead of .htaccess files, you could use an internal mapfunction (tolower).

If you don't have such access, you may want to ckeck for uppercase, rewrite to foo.php internally, using php functions (strtolower) to convert $_SERVER['REQUEST_URI'] to lowercase and issue a 301 redirect via the header() functions.
# httpd.conf
RewriteEngine on
RewriteMap lower int:tolower
RewriteRule [A-Z] ${lower:%{REQUEST_URI}} [R=301,L]
# alternate approach vis .htaccess
RewriteEngine on
RewriteRule [A-Z] /redirect.php?uri=%{REQUEST_URI} [L]

Open in new window


Author Comment

ID: 23714962
Like /Product-blah.html to /product-blah.html but dynamically, because i dont want to have to write a rule for each case.  The other one was if it was product.HTML or Product.HTML to product.html, also doing that dynamically.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month18 days, left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question