Your knowledge base can load under a path of your own website. For example, instead of:
https://yourcompany.help.center
it can load at:
https://yourcompany.com/help
Note
Custom subfolders are available on the Business and Unlimited plans.
Before you start
If you only need something like
help.yourcompany.com, a custom subdomain is simpler: one DNS record and no server setup.A subfolder needs a reverse proxy on your website: your server or CDN forwards requests for
/helpto Helpcenter. The steps below use a Cloudflare Worker.If you're not familiar with proxies or DNS, ask a DevOps or web team member for help.
Add the subfolder in Helpcenter
Go to Settings › Knowledge Base › Domain. Under Custom domain, select Subfolder and enter the full URL, for example https://yourcompany.com/help. Click Save changes.
Switching from a custom subdomain? Clear the subdomain first. Saving a subfolder doesn't remove a subdomain you set earlier, and if both are set, the subdomain is used.
What your proxy needs to do
For every request under your subfolder, the proxy must:
Forward it to your Helpcenter address,
https://yourcompany.help.center, with the subfolder removed from the path. For example,/help/article/1066-…becomes/article/1066-…. Keepyourcompany.help.centeras the host.Add one header,
X-Helpcenter-Base-Path, set to your subfolder path with a leading slash and no trailing slash, for example/help. This tells Helpcenter to build its links under your subfolder.
Create a Cloudflare Worker
Log in to the Cloudflare dashboard for your website and go to Build › Compute & AI › Workers & Pages.
Click Create application in the top right corner.
Choose Start with Hello World!.
Name the worker, for example helpcenter-reverse-proxy, then click Deploy.
Add a route for the Worker
Open the Worker's Settings. Under Domains & Routes, click Add, then choose Route.
Zone: select your website domain (for example
yourcompany.com).Route: enter your subfolder pattern, for example
*yourcompany.com/help*. This catches/helpand everything under it.Failure mode: set to Fail closed (block).
Click Add route.
Update the Worker code
Click Edit code, replace the entire worker.js code with the script below and click Deploy.
Set
HELP_HOSTto your Helpcenter address.Set
PROXY_PREFIXto your subfolder path, with no trailing slash (for example/help, not/help/).
// ONLY edit these
const HELP_HOST = 'yourcompany.help.center';
const PROXY_PREFIX = '/help'; // the path you want your help center to live on
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const originalUrl = new URL(request.url);
if (originalUrl.pathname.endsWith('/') && originalUrl.pathname !== '/') {
originalUrl.pathname = originalUrl.pathname.slice(0, -1);
return Response.redirect(originalUrl.toString(), 301);
}
if (
originalUrl.pathname !== PROXY_PREFIX &&
!originalUrl.pathname.startsWith(`${PROXY_PREFIX}/`)
) {
return fetch(request);
}
// Build the upstream request with the prefix removed
const upstreamUrl = new URL(originalUrl.toString());
upstreamUrl.hostname = HELP_HOST;
if (upstreamUrl.pathname === PROXY_PREFIX) {
upstreamUrl.pathname = '/';
} else if (upstreamUrl.pathname.startsWith(`${PROXY_PREFIX}/`)) {
upstreamUrl.pathname = upstreamUrl.pathname.slice(PROXY_PREFIX.length) || '/';
}
const proxyRequest = new Request(upstreamUrl.toString(), request);
// Tells Helpcenter which subfolder it is served under
proxyRequest.headers.set('X-Helpcenter-Base-Path', PROXY_PREFIX);
return fetch(proxyRequest);
}
Update your robots.txt
Search engines only read the robots.txt at the root of your domain. Add your help center's sitemap to your main site's robots.txt, and make sure it doesn't block your subfolder:
Sitemap: https://yourcompany.com/help/sitemap.xml
Verify the setup
Open https://yourcompany.com/help in a new tab. If your help center loads and its links stay under /help, the setup is complete. Visitors who open your yourcompany.help.center address are taken to your subfolder.
Still need help?
Contact us