Vercel Rewrite: Serve Your Blog at /blog Without Rebuilding
Vercel rewrites can proxy your existing blog into /blog, letting you keep your CMS while consolidating SEO signals on the main domain.
Table of Contents
- When to use Vercel for /blog
- Rewrite pattern
- Caching considerations
- SEO and redirects
- Testing and rollback
- Observability and limits
- Advanced FAQ
- Why choose BlogPath.io
- Related posts
When to use Vercel for /blog
- Your main site is already on Vercel.
- You want simple JSON config and CDN-backed delivery.
- You can manage headers and caching rules in
vercel.json.
Rewrite pattern
- In
vercel.json, add:
{
"rewrites": [
{ "source": "/blog/(.*)", "destination": "https://blog.origin.example.com/$1" }
]
}
- Preserve query strings; forward headers for real IP.
- Exclude admin/login paths from caching; consider blocking direct origin access.
Caching considerations
- Vercel CDN caches static assets; set long TTLs where safe.
- Keep HTML TTL short; bypass on auth cookies.
- Use image optimization sparingly to avoid surprises with CMS media.
SEO and redirects
- 301 old subdomain URLs to
/blog/*. - Set canonicals to
/blog; update sitemap and feeds. - Avoid double hops (ensure origin doesn’t redirect back to subdomain).
Testing and rollback
- Test via preview deployments; validate ToC and internal links.
- Keep DNS TTL low; rollback by reverting
vercel.json. - Monitor 404/500s and Core Web Vitals after cutover.
Observability and limits
- Watch Vercel analytics for cache status and region latency; pay attention to uncached HTML.
- Monitor edge function/ bandwidth limits if you add middleware.
- Log 4xx/5xx and cache misses to tune rewrites and headers.
- Validate LCP/INP via PageSpeed Insights per region.
Advanced FAQ
Can I use Middleware for conditional logic?
Yes, but keep it lightweight. Use rewrites for main routing; middleware for small header tweaks or A/B tests.
How to secure the origin?
Allow only Vercel IPs or require tokens; avoid exposing the origin publicly.
Do image optimizations conflict with CMS media?
Test media-heavy posts; disable optimization if it alters quality/format unexpectedly.
How to purge?
Re-deploy to bust CDN cache or use on-demand ISR where applicable; keep static assets versioned.
Why choose BlogPath.io
- Edge caching + origin shielding without maintaining rewrites.
- No-code setup (DNS-only), with global performance tuned for blogs.
- Reliability, uptime SLAs, and observability included.