Saturday, January 21, 2023

CloudFlare Page Rules 101: Understanding and Implementing Redirects

Redirecting your website to a secure HTTPS connection is a crucial step in ensuring the security and privacy of your website visitors. However, this can become tricky when dealing with different subdomains, such as the "www" subdomain. One way to do this is by using CloudFlare Page Rules to redirect all HTTP traffic to HTTPS Or all non-www to www with HTTPS

In this blog post, I will show you how to set up redirects using CloudFlare Page Rules for couple of different scenarios:

  1. Redirecting all traffic from http://sunilcloudops.blogspot.com/* to https://www.sunilcloudops.blogspot.com/$1
  2. Redirecting all traffic from https://sunilcloudops.blogspot.com/* to https://www.sunilcloudops.blogspot.com/$1
  3. Redirecting all traffic from http://www.sunilcloudops.blogspot.com/* to https://www.sunilcloudops.blogspot.com/$1
  4. Redirecting all traffic of a sub-domain from http://blog.sunilcloudops.blogspot.com/* to https://sunilcloudops.blogspot.com/$1
  5. Redirecting all traffic of a sub-domain from http://blog.sunilcloudops.blogspot.com/* to https://sunilnewdomain.com/$1 - (external domain)

Before we begin, make sure that your website is set up with a valid SSL certificate and that it is active on CloudFlare.

  • Redirecting all traffic from http://sunilcloudops.blogspot.com/* to https://www.sunilcloudops.blogspot.com/$1

    To redirect all traffic from non-www http to https://www, follow these steps:
    • Log in to your CloudFlare account
    • Select the website you want to redirect
    • Click on the "Page Rules" tab
    • Click on the "Create Page Rule" button
    • In the "If the URL matches" field, enter "http://sunilcloudops.blogspot.com/*"
    • In the "Then the settings are" field, select "Forwarding URL"
    • In the "Status code" field, select "301 - Permanent Redirect"
    • In the "Redirect URL/Destination URL" field, enter "https://www.sunilcloudops.blogspot.com/$1"
    • Click on the "Save and Deploy" button






  • Redirecting all traffic from https://sunilcloudops.blogspot.com/* to https://www.sunilcloudops.blogspot.com/$1































  • Redirecting all traffic from http://www.sunilcloudops.blogspot.com/* to https://www.sunilcloudops.blogspot.com/$1


  • Redirecting all traffic of a sub-domain from http://blog.sunilcloudops.blogspot.com/* to https://sunilcloudops.blogspot.com/$




  • Redirecting all traffic of a sub-domain from http://blog.sunilcloudops.blogspot.com/* to https://sunilnewdomain.com/$1 - (external domain)



Thanks for reading, CloudOps Signing Off! 😊

        


No comments:

Post a Comment