Redirects
If you have an alias domain that only forwards traffic to another domain, you can set up redirects directly within Cloudflare.
-
Make sure that your alias domain has a proxied that properly resolves DNS queries. You may also want to include a record for the
wwwsubdomain.Type Name IPv4 address Proxy status A @192.0.2.1Proxied A www192.0.2.1Proxied -
Log in to the Cloudflare dashboard and select your account.
-
Go to Website.
-
Select the appropriate website.
-
Go to Rules > Page Rules.
-
Select Create Page Rule.
-
Enter a source URL pattern like stop-tihange.eu/.
-
Under When incoming requests match.
-
Pick a setting Forwarding URL and select status code 301 - Permanent Redirect
-
Enter destination URL use $1, $2, etc. for each asterisk used in the source url, e.g. https://www.stop-tihange.org/$2
-
Save Page Rule
based on cloudflare
At least for HSTS the first redirect from HTTP to HTTPS must be done on the same domain. For that the rule Enforce HTTPS seems not to work correctly, in each zone will be established a first rule as followed.:
- http://example.com/ –> https://$1example.com/$2
- …