Hi,
In my current project, this is how we are setting ErrorDocument:
SetEnvIfNoCase Request_URI "^/(group|career|uk|se)/(en|sv)" MARKET=$1
SetEnvIfNoCase Request_URI "^/(group|career|uk|se)/(en|sv)" LANGUAGE=$2
# If market or language does not exists, they are set to default values
SetEnvIfNoCase MARKET ^\s*$ MARKET=group
SetEnvIfNoCase LANGUAGE ^\s*$ LANGUAGE=en
ErrorDocument 400 /%{ENV:MARKET}/%{ENV:LANGUAGE}/error-pages/4xx
ErrorDocument 401 /%{ENV:MARKET}/%{ENV:LANGUAGE}/error-pages/4xx
ErrorDocument 403 /%{ENV:MARKET}/%{ENV:LANGUAGE}/error-pages/4xx
ErrorDocument 404 /%{ENV:MARKET}/%{ENV:LANGUAGE}/error-pages/4xx
ErrorDocument 405 /%{ENV:MARKET}/%{ENV:LANGUAGE}/error-pages/4xx
And, its working fine. Now major concern is whenever a new market or new language in existing market is added, we need to change search criteria in dispatcher. Is there any way to dynamically populate the market and language in apache dispatcher config instead of using hard coded values?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @girtorapankaj ,
Instead of configuring error pages from dispatcher you can write custom error handler and using that can redirect to specific error pages. There is a explanation here
Hi @girtorapankaj ,
Instead of configuring error pages from dispatcher you can write custom error handler and using that can redirect to specific error pages. There is a explanation here
Instead of hardcoding it you should go for the variable based for each region and configure it in region specific virtualhost like
why you need to have 8 different vhost file? I think there is some confusion..!
you can create single virtualhost.conf file for your entire application and there you can create section for every locale and put your configuration there like:
Hi Umesh,
Thanks for clarifying.
But issue is when ever a new market/language gets added, we need to update the variable(s) to include that market or language. This is what we want to avoid.
Would it be possible for you to share your contact no so that I can explain in details with more information.
Regards
Pankaj
Hi @girtorapankaj!
Actually, your solution looks quite good to me. If you want it to be more generic, you could replace the regular expressions in the first two lines with something like
SetEnvIfNoCase Request_URI "^/(group|career|[a-z]{2})/([a-z]{2})" MARKET=$1
If you are able to produce a dispatcher/vhost configuration that does not need additional maintenance/configuration for future languages and markets depends primarily on your content structure. The default, most recommended structure usually has a "/MARKET/LANGUAGE" part in it as per your example. Personally, I always recommend to stick to standard country and language two-letter ISO codes here. That makes a lot of things much easier. In your example, you have some dissenting market identifiers ("group", "career"). While there may be good reasons and totally valid business cases behind that decision it makes things a bit more difficult when it comes to producing generic, low-/non-maintenance configurations. However, if you are able to stick to these two-letter codes in the future a configuration with my example regular expression will work without additional changes.
While the solution that @Ritesh_Mittal proposed is also another valid approach, I recommend to handle the most basic configurations on dispatcher level. The reason behind that gets a bit clearer if you look not only at the 4xx error code range but also the 5xx HTTP status codes. If your AEM instance is in any kind of trouble (e. g. down or any other error state) and returns a HTTP 500 status it is very likely that it will not be able to actually render a nicely styled error page for that status code and send it to the end user.
My recommendation is:
Apart from that you may also want to check the ACS AEM Commons Error Page Handler.
Hope that helps!
Views
Likes
Replies
Views
Likes
Replies