Hi,
I am trying to redirect the home page of a website based on the browser language of the user. For doing this, I have put in the following rule which is not working.-
#Redirect for Portuguese language based on HTTP header
RewriteCond %{HTTP:Accept-Language} pt [NC]
RewriteCond %{HTTP_HOST} xxx.lat [NC]
RewriteRule ^(.*)$ https://www.xxx.lat/pt$1 [R=301,L]
Is there any issue with the way the accept language header is used? Can anyone please point out the issue here?
Solved! Go to Solution.
Views
Replies
Total Likes
make sure dispatcher allow those headers,
This is in case you want those header in AEM Publish
Can you check if header
HTTP:Accept-Language
is set and propagate to apache
if not then it will not work
You can test here https://htaccess.madewithlove.com/
Thanks @arunpatidar for your reply. I am adding this rule in my dispatcher. Can you give any direction how to set and propagate this to apache, as I am a bit new to this area?
make sure dispatcher allow those headers,
This is in case you want those header in AEM Publish
Many thanks @arunpatidar . These clientheaders (including 'accept-language') are already allowed/included under /clientheaders. Still, it is not working.
The second link shared is for response headers, which i think wont be required because I want to access the request header.
Do you think there is any error with the format or case?
On second thought, is this the right approach to handle language based redirects? should it be done through js scripts in your view?
We are managing this at CDN level, we have rules to redirect to users language home page based on language and country if user is coming from different geographical area.
You can manage this at CDN or at apache. Using javascript may help if you put in head section and do a redirect before page completely loaded.
Views
Likes
Replies