Skip to content
Cloudflare Docs

Redirect requests from one domain to another

Create a redirect rule to redirect all requests to a different domain, maintaining all functionality, except for the discontinued HTTP service (port 80).

In this example the original domain was replaced with a different domain. All functionality was maintained, except for the HTTP service (port 80) which was discontinued.

Create a redirect rule with the following configuration:

When incoming requests match

  • Wildcard pattern
    • Request URL: http*://example.com/*

Then

  • Target URL: https://example.net/${2}
  • Status code: 301
  • Preserve query string: Enabled

This configuration will perform the following redirects:

Request URLURL after redirectStatus code
http://example.com/https://example.net/301
https://example.com/https://example.net/301
https://example.com/my/path/to/page.htmhttps://example.net/my/path/to/page.htm301
https://example.com/search?q=termhttps://example.net/search?q=term301