Cloudflare guide
How to add a blog at /blog with a Cloudflare Worker
If your domain is on Cloudflare, you can add a blog at yourbrand.com/blog without touching your website, whatever it is built with. A small Cloudflare Worker sends /blog to your free Outrank blog and everything else to your site, as before.
Free with Outrank Blogs. No credit card needed. See what is included
Subfolder
Your blog at yourbrand.com/blog
This works in front of any website, including site builders that do not let you add rewrites, as long as your domain’s traffic goes through Cloudflare.
Step by step
Set up your blog on Cloudflare
- 1Create your free blog: enter your website and pick a template. It is live in about a minute.Start here
- 2In Outrank, open Blog → Settings → Domain and choose “Subfolder”. Enter your website address, such as yourbrand.com, keep the path /blog and click Continue. Outrank shows the code for your setup with your blog’s address already filled in.
- 3Check that your domain’s DNS is on Cloudflare and that the record for your website has the orange cloud (proxied) turned on.
- 4In Cloudflare, open Workers & Pages, create a Worker and replace its code with the snippet below.
- 5Add a route yourbrand.com/blog* to the Worker (Settings → Domains & Routes).
- 6Click Check now in Outrank.
- 7Add a “Blog” link to your site’s header or footer that points to /blog.
const ORIGIN_HOST = 'o--your-blog-id.outrankblog.com';
const PREFIX = '/blog';
const rewriteLocation = (location, url) => {
try {
const target = new URL(location, `https://${ORIGIN_HOST}`);
if (target.hostname !== ORIGIN_HOST) return location;
return `${url.origin}${PREFIX}${target.pathname === '/' ? '' : target.pathname}${target.search}`;
} catch {
return location;
}
};
export default {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname !== PREFIX && !url.pathname.startsWith(`${PREFIX}/`)) {
return fetch(request);
}
if (url.pathname === `${PREFIX}/`) {
return Response.redirect(`${url.origin}${PREFIX}${url.search}`, 301);
}
const upstream = new URL(request.url);
upstream.hostname = ORIGIN_HOST;
upstream.pathname = url.pathname.slice(PREFIX.length) || '/';
const headers = new Headers(request.headers);
headers.set('X-Forwarded-Host', url.hostname);
headers.set('X-Forwarded-Proto', 'https');
headers.set('X-Outrank-Base-Path', PREFIX);
const response = await fetch(upstream.toString(), {
method: request.method,
headers,
body: request.method === 'GET' || request.method === 'HEAD' ? undefined : request.body,
redirect: 'manual',
});
const proxied = new Response(response.body, response);
const location = proxied.headers.get('Location');
if (location) proxied.headers.set('Location', rewriteLocation(location, url));
return proxied;
},
};
Example only. In your dashboard, Outrank shows this code with your blog’s own address filled in.
Tips for Cloudflare
- Cloudflare’s free Workers plan covers 100,000 requests a day, which is plenty for most blogs.
- If your website uses www, add the route for www.yourbrand.com/blog* too.
Want the posts written for you?
Outrank can research keywords and publish 30 SEO articles a month to your blog, on autopilot.
See plansCompare and set up
Moving from another platform?
See how Outrank Blogs compares with the platforms you know, and how to add it to the website you already have.
Comparisons
- Outrank Blogs vs BloggerBoth are free. Only one can live at yourbrand.com/blog.
- Outrank Blogs vs WordPress.comYour own domain and no ads, without a paid plan.
- Outrank Blogs vs MediumBuild your own domain’s authority, not medium.com’s.
- Outrank Blogs vs SubstackA blog on your own domain, with no revenue cut.
Setup guides
FAQ
Adding a blog to Cloudflare: questions
Short answers to what people ask most.
Why put the blog in a subfolder instead of a subdomain?
Does this work with Webflow, Framer or Shopify?
Does connecting my own domain cost anything?
Start today

