Skip to main content

Cloudflare Pre-sale Redirect Rules

This document describes how to configure Cloudflare redirect rules for book pre-sales. These rules intercept requests for a book that hasn't been released yet and redirect users to a pre-sale "dummy" issue.

Context​

Publishers like Grupo Planeta link to our platform using URLs built with the book's external_id (ISBN). When a book is in pre-sale:

  1. The real book may not exist in our system yet (Bookwire sends it on release date)
  2. A "dummy" pre-sale issue exists with a special ISBN format, example: Pre-{ISBN}
  3. We need to redirect users hitting the real ISBN URL to the pre-sale issue

Prerequisites​

Before configuring the redirect, you need:

RequirementDescriptionExample
Real ISBNThe ISBN of the book being pre-sold9786287860186
Pre-sale ISBNThe dummy issue's external_id (format: Pre-{ISBN})Pre-9786287860186
Pre-sale issue existsVerify the dummy issue exists in the systemQuery DB or check admin
Cloudflare accessAccess to publica.la domain in Cloudflare dashboard

Procedure​

Step 1: Access Cloudflare Rules​

  1. Go to Cloudflare Dashboard
  2. Select publica.la domain
  3. Navigate to Rules > Redirect Rules
  4. Click Create rule

Step 2: Configure the Rule​

Rule Name​

Use a descriptive name following this pattern:

production - Pre-sales-{Publisher} - {ISBN}

Example: production - Pre-sales-Grupo Planeta - 9786287860186

Filter Expression​

Select "Custom filter expression" and configure:

FieldOperatorValue
Hostnameequalsfarfalla-entry-point.publica.la
AND
URI Pathequals/library/publication/external-id/{REAL_ISBN}

Example values:

  • Hostname: farfalla-entry-point.publica.la
  • URI Path: /library/publication/external-id/9786287860186

Expression Preview​

The resulting expression should look like:

(http.host eq "farfalla-entry-point.publica.la" and http.request.uri.path eq "/library/publication/external-id/9786287860186")

Redirect Configuration​

SettingValue
TypeStatic
URL/library/publication/external-id/{PRE_SALE_ISBN}
Status Code302
Preserve query stringChecked

Example URL: /library/publication/external-id/Pre-9786287860186

Rule Order​

Set "Ubicado en" to "Primero" to ensure the rule takes priority.

Step 3: Save and Deploy​

Click "Guardar" to save and deploy the rule immediately.

Optional: Add Slug Redirect​

If the real book already exists in the system (uploaded by Bookwire), users might access it via its slug. Add an OR condition to also redirect slug-based URLs:

(http.host eq "farfalla-entry-point.publica.la" and http.request.uri.path eq "/library/publication/external-id/9786287860186")
or (http.request.uri.path eq "/library/publication/{REAL_BOOK_SLUG}")

This ensures both access paths redirect to the pre-sale.

Testing​

Test the Redirect​

Access the real book URL and verify it redirects to the pre-sale:

curl -I "https://farfalla-entry-point.publica.la/library/publication/external-id/9786287860186"

Expected response:

HTTP/2 302
location: /library/publication/external-id/Pre-9786287860186

Test in Browser​

  1. Open: https://{tenant-domain}/library/publication/external-id/9786287860186
  2. Verify you land on the pre-sale page
  3. Check the URL shows the pre-sale ISBN or slug

Test from Publisher's Site​

If possible, test the full flow from the publisher's website (e.g., Planeta's official store) to ensure their links correctly redirect to the pre-sale.

Output​

After successful configuration:

  • Users accessing the real ISBN URL are redirected to the pre-sale issue
  • The redirect uses HTTP 302 (temporary) so it can be removed after launch
  • Query strings are preserved for tracking/analytics

Post-Launch Cleanup​

After the book is officially released:

  1. Go to Cloudflare Rules > Redirect Rules
  2. Find the pre-sale rule by name
  3. Either disable or delete the rule
  4. Verify the real book is accessible at its ISBN URL
X

Graph View