Redirect to different domain and URI

Hello,

I need to be able to redirect dynamically a few pages from one domain to a different domain and URI.
Example: https://domain1.com/(subdirectory)/(page).php to https://domain2.com/(page).php

Basically removing the subdirectory on the new domain.

My google-fu isn’t working to find a way do this.

To redirect from https://domain1.com/(subdirectory)/(page).php to https://domain2.com/(page).php, you can use Cloudflare Page Rules:

  1. Log in to your Cloudflare account.
  2. Go to the Page Rules app.
  3. Click “Create Page Rule” for domain1.com.
  4. Set the target URL to https://domain1.com/(subdirectory)/*.
  5. Choose the “Forwarding URL” setting and select “301 - Permanent Redirect”.
  6. Set the destination URL to https://domain2.com/$1.php, where $1 represents the wildcard match from the original URL.
  7. Save and deploy the rule.

This will redirect all pages from the specified subdirectory in domain1.com to the same page in domain2.com without the subdirectory.