Need a rewrite rule based on a custom http header

自作多情 提交于 2019-12-11 08:38:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!