Expand my Community achievements bar.

SOLVED

\/etc/map/http - How to change lower case to UPPER case in regex in /etc/map

Avatar

Level 4

Hi all,

 
End user will hit our site using following pattern for locale (/mysite/us/en/home.html) but in our CQ this page is located under /content/mysite/en_US.html . And top of this we have 50 different locales.
 
So we can write rules on webserver which is pretty simple and things works fine. 
 
Now when we am going to write /etc/map/http rule then i have to repeat same rule 50 times for 50 locales. Is there any way to CONVERT lower case to UPPER CASE . This way I have to write only ONE RULE in /etc/map. I read on some blog that if we add "\U" in the REGEX then it will convert the value to UPPER CASE. But some how this is not working in CQ (\E meaning end of case conversion)
http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
 
 
For example (below is the rule which i added)
 
sling:internalRedirect  /content/mysite/$1_\\U$2\\E/$3.html
sling:match           mysite/([^/])/([^/]+)/([^/])
 
When I test my rule in Sling Resolver seems like it does not recognize \U or \E and it just displys them as U & E letter 
 
below is the input and output
input : /mysite/de/de/home
output : /content/mysite/de_UdeE/home.html   (see in BOLD nothing happened here instead of displaying U & E)
 
Please let me know if you know of a way to deal with this situation.
 
Thanks in advance.
1 Accepted Solution

Avatar

Correct answer by
Level 10

Best practice for this is (managing different domains) is talked about here:

http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/

not sure of other community members but I have never heard of simplying using uppercase.

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Best practice for this is (managing different domains) is talked about here:

http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/

not sure of other community members but I have never heard of simplying using uppercase.

Avatar

Level 9

Why does Sling not handle \U...\E?

It's likely because Java does not support the Perl preprocessing operations \l, \u, \L, and \U.

http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html

Avatar

Level 10

It is not possible in jcrresolver. You might need to write a filter or deal at web server level with mod_rewrite

http://stackoverflow.com/questions/18440287/filter-request-url-before-any-processing-in-cq5-6

Avatar

Level 4

Thanks K Kendall , Sham  , smacdonald2008  for your valuable reply on this. Seems like its not possible :)