问题
Cloudflare is sending a header CF_IPCountry on all requests to our server, which contains the country code from which the request originated.
We need to redirect (permanently, including POST requests) all requests coming from New Zealand (CF_IPCountry = NZ) to a subdomain nz.foo.co.nz so that it will be served as domestic traffic and not from cloudflare's servers overseas.
What condition and rule do I need?
回答1:
Try using the %{HTTP:<headername>}
var:
RewriteCond %{HTTP:CF_IPCountry} ^NZ$ [NC]
RewriteRule ^(.*)$ http://nz.foo.co.nz/$1 [L,R=301]
来源:https://stackoverflow.com/questions/23121496/need-a-rewrite-rule-based-on-a-custom-http-header