Using .htaccess to easily redirect AU traffic to au.example.com

Hello Team

My .htaccess skills aren’t really up to scratch so I’m asking for some help from the community :slight_smile:

I have a website at example.com and some some content relevant only to Australia at au.example.com - I want to automatically redirect any customer visiting from Australia to au.example.com while obviously allowing users from any other region to to go to example.com as normal.

I also have the domain behind Cloudflare, therefore I have the IP Geolocation setting on, which allows the IP Geolocation information from the CF-IPCountry HTTP header.

I already had a Google around and I found this for .htaccess:

SetEnvIf CF-IPCountry “(.)$” Country=$1
RewriteCond %{ENV:Country} BE
RewriteRule ^(.
)$ https://be.example.com/$1 [R,L]

This is as per https://community.cloudflare.com/t/redirecting-specific-country-to-sub-domain/12688/6

Will this snippet be valid? I would really appreciate any help with this task!

Thanks so much!