views:

30

answers:

1

I have the following Apache Rewrite rule

<IfModule rewrite_module>
     RewriteEngine on
     RewriteMap tolowercase int:tolower
     RewriteCond $2 [A-Z] 
     RewriteRule ^(.*)/(.*).html$ $1/${tolowercase:$2}.html [R=301,L]
</IfModule>

that changes this:

http://localhost.localdomain.com/FooBarBaz.html

to this:

http://localhost.localdomain.com/foobarbaz.html

I'd like to port it to this tuckey.org URL Rewrite Filter.

What is an equivalent rule that I could use to make the URL lowercase? I'm particularly interested in how to form the condition element.

Here's my first cut at the rule, but it doesn't work, even without the condition:

<rule>
    <name>Force URL filenames to lower case</name>
    <from>^(.*)/(.*).html$</from>
    <to type="permanent-redirect" last="true">$1/${lower:$2}.html</to>
</rule>
A: 

Here's what I eventually settled on:

<rule match-type="regex">
    <name>Force URL filenames to lower case</name>
    <condition type="request-uri" casesensitive="false" operator="notequal">^.*/a4j.*$</condition>
    <condition type="request-uri" casesensitive="true">^.*/.*[A-Z].*.html$</condition>
    <from>^(.*)/(.*).html$</from>
    <to type="permanent-redirect" last="true">$1/${lower:$2}.html</to>
</rule>

The first condition is to prevent the rule from running on A4J AJAX requests.

braveterry