🚀 How to Redirect Blogger/Blogspot Domain from WWW to Non-WWW
Want a cleaner and SEO-friendly URL like https://abdullahcoded.site instead of https://www.abdullahcoded.site? In this guide, I’ll show you step-by-step how to set up your Blogger domain to use the root domain (non-WWW) with the help of Cloudflare.
⚙️ How It Works
We’ll use a 301 redirect to automatically send all traffic from www
to the root domain. Cloudflare Workers will then proxy your Blogger content so it displays correctly without www — and yes, it’s SEO safe ✅.
🌐 Step 1 – Configure Cloudflare DNS
- A Record: abdullahcoded.site → 216.239.32.21, 216.239.34.21, 216.239.36.21, 216.239.38.21 → Proxied
- CNAME: www → ghs.google.com → Proxied
📝 Step 2 – Blogger Settings
Add your domain with www in Blogger as usual. Important: Uncheck “Redirect to www” in Blogger settings!
⚡ Step 3 – Create Cloudflare Worker
Go to Cloudflare → Workers & Pages → Create Worker → Deploy, then click Edit Code and paste the following:
const WWW = 'www.abdullahcoded.site';
const ROOT = 'abdullahcoded.site';
export default {
async fetch(request) {
const reqUrl = new URL(request.url);
if (reqUrl.hostname === WWW) {
reqUrl.hostname = ROOT;
reqUrl.protocol = 'https:';
return Response.redirect(reqUrl.toString(), 301);
}
const originUrl = new URL(request.url);
originUrl.hostname = WWW;
originUrl.protocol = 'https:';
const resp = await fetch(new Request(originUrl.toString(), request), {
cf: { cacheEverything: true }
});
const ct = resp.headers.get('content-type') || '';
if (ct.includes('text/html')) {
return new HTMLRewriter()
.on('link[rel="canonical"]', {
element(el) {
const href = el.getAttribute('href');
if (href) {
try {
const u = new URL(href, originUrl);
if (u.hostname === WWW) {
u.hostname = ROOT;
el.setAttribute('href', u.toString());
}
} catch {}
}
}
})
.on('a', {
element(el) {
el.setAttribute('href', el.getAttribute('href').replace(WWW, ROOT));
}
})
.transform(resp);
}
return resp;
}
};
👉 Replace yourdomain.com with your actual domain and click Deploy.
🔗 Step 4 – Assign Routes
Go to Workers → Settings → Domains & Routes and add:
abdullahcoded.site*
www.abdullahcoded.site/*
🔒 Step 5 – Enable SSL/HTTPS
From Cloudflare, go to SSL/TLS → set mode to Full → Save. Then enable Always Use HTTPS under Edge Certificates.
✅ Pros of Non-WWW Setup
- Clean & professional URLs (https://abdullahcoded.site)
- SEO-friendly 301 redirect (Google recognizes canonical as non-WWW)
- Free SSL + DDoS protection from Cloudflare
- No data/config changes inside Blogger
⚠️ Cons of Non-WWW Setup
- Slight latency (+50–100ms per request)
- Free Cloudflare Worker limit: 100,000 requests/day
- High-traffic sites may require paid plan (~$5/month)
🎯 Final Thoughts
For small to medium blogs, using non-WWW gives you cleaner URLs, better SEO, and an overall professional look. If your site gets huge traffic, you might stick with www — it’s still SEO-friendly and widely used. The choice is yours!
Copyright ©
ᗩᗷᗪᑌᒪᒪᗩᕼ ᑕᗝᗪᗴᗪ