Redirect rule based on accept language | Community
Skip to main content
Level 2
October 11, 2022
Solved

Redirect rule based on accept language

  • October 11, 2022
  • 1 reply
  • 2239 views

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? 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

arunpatidar
Community Advisor
Community Advisor
October 11, 2022

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/ 

 

 

Arun Patidar
Gunjan881Author
Level 2
October 11, 2022

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?