How can I convert this Apache Rewrite rule to a Tuckey UrlRewriteFilter rule?

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>

which changes this:

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

:

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

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

What is the equivalent rule that I could use to create a lowercase URL? I am particularly interested in how to form a condition element.

Here is my first cut by the rule, but it does not work, even without a 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>
+3
source share
2 answers

Here is what I finally decided:

<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 prohibit rule execution for A4J AJAX requests.

+4

,

( AJAX). , caseensitive, from. , :

<rule match-type="regex">  
    <note>Force URL to lower case</note>
    <from casesensitive="true">^.*[A-Z].*$</from>
    <to type="permanent-redirect" last="true">${lower:$0}</to>  
</rule>

. ( ).

, URL Rewrite Filter, , . , . , , , .

+1

Source: https://habr.com/ru/post/1764020/


All Articles