Hi Folks,
I need to define redirect rule to handle where one set of languages to redirect to site.com/en.html while other set of languages to redirect to site.com/fr.html
for example cn, de, fr to redirect site.com/en.html
while
it, ja, zh to redirect site.com/fr.html.
How can I define such rule?
Is it possible like?
RewriteCond %{HTTP:Accept-Language} cn,de,fr [NC]
RewriteCond %{HTTP_HOST} site.com/en [NC]
RewriteCond %{HTTP:Accept-Language} it,ja,zh[NC]
RewriteCond %{HTTP_HOST} site.com/fr[NC]
Any help is highly appreciated.
Thanks,
Pradeep
Solved! Go to Solution.
Views
Replies
Total Likes
May be you can try something as below
RewriteCond %{HTTP:Accept-Language} ^(en|es|fr|kk) [NC]
Regards
You can use Rewrite rules on Apache to redirect your HTTP request
Apache <-> Dispatcher <-> publisher
RewriteRule site.com/en.html /content/site/en.html [Your AEM content page path to allow requests from the dispatcher ]
I need to handle one set of languages to redirect to en version of the site. 2nd set of languages to redirect fr version of the site.
How to handle this scenario in dispatcher?
You can write Apache rewrite rules for each individual language to have redirect to appropriate location
How to define rule to handle multiple languages in one rule ? So that I can club all languages in two rules to make this simple.
Otherwise we have to write 100 rules for 100 languages. This solution will be complex to maintain.
May be you can try something as below
RewriteCond %{HTTP:Accept-Language} ^(en|es|fr|kk) [NC]
Regards
Use pipe like (cn|de|fr)/.*$ [NC]
This is the redirect rule
<IfModule mod_rewrite.c>
#Redirect for English language based on HTTP header
RewriteCond %{HTTP:Accept-Language} ^(en|cn|de|fr) [NC]
RewriteCond %{HTTP_HOST} localhost [NC]
RewriteRule ^(.*)$ http://www.localhost:8080/content/we-retail/us/es$1 [R=301,L]
</IfModule>
this is the clientheaders
/clientheaders
{
# Forward all request headers that are end-to-end. If you want
# to forward a specific set of headers, you'll have to list
# them here.
"CSRF-Token"
"X-Forwarded-Proto"
"referer"
"user-agent"
"authorization"
"from"
"content-type"
"content-length"
"accept-charset"
"accept-encoding"
"accept-language"
"accept"
"host"
"max-forwards"
"proxy-authorization"
"proxy-connection"
"range"
"cookie"
"cq-action"
"cq-handle"
"handle"
"action"
"cqstats"
"depth"
"translate"
"expires"
"date"
"dav"
"ms-author-via"
"if"
"lock-token"
"x-expected-entity-length"
"destination"
"PATH"
}
When I am hitting the URL
http://localhost:8080/content/we-retail/us/en.html
As per the en language rule It should redirect to http://localhost:8080/content/we-retail/us/es.html
Which is not happening.
Am I missing anything here?
you can also start the dispatcher in debug mode to check what’s going on there.
https://nhutils.ru/blog/en/how-to-set-up-redirect-by-language-in-htaccess/
I have checked dispatcher logs. Nothing much I got from logs.
Below rewrite rule is not working
RewriteCond %{HTTP:Accept-Language} ^(en|cn|de|fr)/.*$ [NC]
RewriteCond %{HTTP_HOST} dev-test.site.com [NC]
RewriteRule ^(.*)$ http://dev-test.site.com/tc$1 [R=301,L]