Subdirectory
Custom subdirectories are available under the Startup Plan.
Set up Cloudflare
Sign up for an account and add your site to Cloudflare.
Create Cloudflare Worker
Navigate to the Workers > Create a service
. You should be able to presented with the following screen where you can create a new Cloudlfare worker.

Add custom domain
Once the worker is created, navigate to the worker settings and then Triggers > Custom Domains
. Click on Add Custom Domain
to then add your following domains into the list.

If you have trouble setting up custom subdirectory, contact our support team and we’ll walk you through upgrading your hosting with us.
Edit Worker Script
Click on Quick edit
and add the following script into the worker’s code.
Edit DOCS_URL
by replacing [SUBDOMAIN] with your unique subdomain and
CUSTOM_URL
with your website’s base URL.
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
try {
const urlObject = new URL(request.url);
// If the request is to the docs subdirectory
if (/^\/docs/.test(urlObject.pathname)) {
// Then Proxy to Mintlify
const DOCS_URL = '[SUBDOMAIN].mintlify.dev';
const CUSTOM_URL = '[YOUR_DOMAIN]';
let url = new URL(request.url);
url.hostname = DOCS_URL;
let proxyRequest = new Request(url, request);
proxyRequest.headers.set('Host', DOCS_URL);
proxyRequest.headers.set('X-Forwarded-Host', CUSTOM_URL);
proxyRequest.headers.set('X-Forwarded-Proto', 'https');
return await fetch(proxyRequest);
}
} catch (error) {
// if no action found, play the regular request
return await fetch(request);
}
return await fetch(request);
}
Click on Save and deploy
and wait for the changes to propagate (it can take up to a few hours).
Reach out to Mintlify team
Once completing the Cloudflare setup, the Mintlify team will setup the subdirectory settings in your deployment. Reach out over email or in our community.
Was this page helpful?