Cloudflare Docs
Support
Support
Visit Support on GitHub
Set theme to dark (⇧+D)

Using Page Rules to rewrite Host Headers

Customers can rewrite Host Headers using the Cloudflare Rules app. This feature is currently available for domains on the Enterprise plan.

A common use case for this functionality is when your content is hosted on an Amazon S3 bucket. Amazon has designed their system to only accept host headers that have the same name as the bucket hosting your content. In this way, a request to “Host: your-domain.com” must be rewritten to “Host: your-bucket.s3.amazonaws.com", or else the request will be denied.

To rewrite the Host Header:

1. Go to Rules > Page Rules and create a new Page Rule.

2. Specify the URL to match.

3. In Pick a Setting, select Host Header Override. Then, enter the override value.

4. Click Save and Deploy.

Now, any request matching the URL you specified will have the host header overridden to the one you entered in the Host Header Override text box. Refer to the example below:

Example configuration of a Page Rule that overrides the Host Header for all requests to theburritobot.com