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:
- The real book may not exist in our system yet (Bookwire sends it on release date)
- A "dummy" pre-sale issue exists with a special ISBN format, example:
Pre-{ISBN} - We need to redirect users hitting the real ISBN URL to the pre-sale issue
Prerequisites
Before configuring the redirect, you need:
| Requirement | Description | Example |
|---|---|---|
| Real ISBN | The ISBN of the book being pre-sold | 9786287860186 |
| Pre-sale ISBN | The dummy issue's external_id (format: Pre-{ISBN}) | Pre-9786287860186 |
| Pre-sale issue exists | Verify the dummy issue exists in the system | Query DB or check admin |
| Cloudflare access | Access to publica.la domain in Cloudflare dashboard |
Procedure
Step 1: Access Cloudflare Rules
- Go to Cloudflare Dashboard
- Select publica.la domain
- Navigate to Rules > Redirect Rules
- 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:
| Field | Operator | Value |
|---|---|---|
| Hostname | equals | farfalla-entry-point.publica.la |
| AND | ||
| URI Path | equals | /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
| Setting | Value |
|---|---|
| Type | Static |
| URL | /library/publication/external-id/{PRE_SALE_ISBN} |
| Status Code | 302 |
| Preserve query string | Checked |
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
- Open:
https://{tenant-domain}/library/publication/external-id/9786287860186 - Verify you land on the pre-sale page
- 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:
- Go to Cloudflare Rules > Redirect Rules
- Find the pre-sale rule by name
- Either disable or delete the rule
- Verify the real book is accessible at its ISBN URL