![Ogunnowo487](https://vmapp.org/images/player/000default.jpg)
: Is it possible to check the case on Apache redirects or aliases? I have a big website (15,000 pages) with a log list of redirects (about 800) that have been used in marketing pieces for years.
I have a big website (15,000 pages) with a log list of redirects (about 800) that have been used in marketing pieces for years. My Apache server has been running mod_rewrite for the past 10 years or so to force all requests to lower case. So a user could put in /CamelCase and Apache would read it as /camelcase and my corresponding redirect would work.
I'm switching over my site to Drupal at the end of the month and the server needs to become case sensitive. I assumed that I could use mod_spelling on my list of redirects so people could continue to type in a URL however they choose and it would continue to work. Mod_spellin, however, does not scan through the list of redirects so it does not work.
I have enough staff to have them go through the list of redirects and add in any case-sensitive variants but this would make my already large listing of redirects grow by 2 to 4 times. Hopefully I don't have to go down that route. I thought there might be a way to use mod_rewrite to test different cases on redirects but I can't get anything to work.
So, does anyone have ideas?
More posts by @Ogunnowo487
2 Comments
Sorted by latest first Latest Oldest Best
A "lowercase" mapping can be applied first to the key passed to the rewrite map.
RewriteMap permredirects "dbm:/path/to/dbm/file.map"
RewriteMap lowercase int:tolower
RewriteCond ${permredirects:${lowercase:}} !=""
RewriteRule ^(.*) "${permredirects:${lowercase:}}" [L,R=301]
After some research, I'm pretty sure that I'll just use a RewriteMap that will contain all of case variants. It will take some work to create most of the possibilities people might type in but as long as I can hit 90% of them I'll consider that a success. For those with similar issues, I'll document how it is done.
Start by creating the rewrite map file. This is just a text file on the server with the case variants listed.
## case_variants.txt
CamelCase camelcase
CAMELCASE camelcase
Since this is a list I won't need to update often, I converted it to a DBM hash file so Apache can index it and get to the desired key faster. To do this, this command was run on the server as root.
$ httxt2dbm -i /etc/httpd/case_variants.txt -o /etc/httpd/case_variants.map
Now I update the Apache directives to check this map file and re-write the request as needed. Note that this statement cannot be in a directory statement.
RewriteEngine on
RewriteMap case2check dbm:/etc/httpd/case_variants.map
# if I wanted to use the text file instead, uncomment the following line
# RewriteMap case2check txt:/etc/httpd/case_variants.txt
RewriteRule ^/(.*)$ /${case2check:|} [PT]
All of this, and more, is explained on the Apache rewrite map page. If I missed anything or my process could be improved upon post it below.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.