I’m using Cloudflare, which has a request header named CF-IPCountry
that holds the value of the country the user is visiting from. Example: DE
for Germany.
I need to serve a different image in certain cases. For example, for all users, the France flag will be loaded with this request: https://example.com/static/img/lang/fr.png
But, if the CF-IPCountry
request header value is CA
(Canada), then all requests for https://example.com/static/img/lang/fr.png
should actually load this other file https://example.com/static/img/lang/fr-ca.png
I’ve detected those cases for these visitors:
CA
: canadians should loadfr-ca
instead of the french flagfr
BR
: brazilians should loadpt-br
instead of the portuguese flagpt
How can this logic be implemented on my .htaccess
file?