Use this when your domain points to Vercel but your email stays at SiteGround, Hostinger, or cPanel hosting.
Related deep-dive: How to Fix SiteGround Webmail 404 on Vercel.
What the Fix Should Protect
The route is not just a convenience redirect. It protects a common migration edge case: the website moves to Vercel, but mailbox access remains with the legacy hosting provider.
The safe version of the fix should:
- keep provider login links working
- preserve required query strings
- avoid writing tokenized URLs to application logs
- leave MX, SPF, DKIM, and DMARC records alone
- return a predictable redirect instead of a branded 404 page
That last point matters for support. Staff will keep typing the webmail shortcut, and hosting providers often generate nested login links that include session-style parameters.
Prerequisites
- Next.js App Router project
- webmail host URL from your provider
- deploy access to Vercel
Step-by-Step
Step 1: Create route files
Create two App Router handlers: one for the root webmail shortcut and one catch-all handler for nested webmail paths.
Step 2: Add root redirect
The root redirect should forward visitors to your provider's webmail host with a temporary redirect. Keep the provider host in configuration and avoid logging any incoming query strings.
Step 3: Add catch-all redirect
The catch-all redirect should preserve the nested path and original query string so tokenized provider login links keep working.
Step 4: Deploy and verify
Test both the plain webmail shortcut and a provider-generated nested token path from the hosting dashboard.
Both should forward to your provider's webmail host.
Migration QA Notes
Run this check during the same launch window as DNS, redirect, and Search Console review.
For client migrations, I usually verify:
- the public website resolves on the new host
- mail DNS still points to the mail provider
- the webmail shortcut redirects without exposing token values
- nested webmail paths preserve the provider path
- the route does not appear in the public sitemap
- support staff know the canonical webmail URL if the shortcut ever changes
If the site uses analytics middleware, exclude this redirect path from event payloads that could capture query strings. Tokenized login URLs should be treated like sensitive operational data.
Provider Pattern Notes
Most SiteGround, Hostinger, and cPanel-style providers expose webmail through a provider host rather than your Vercel app. That means the app route should only forward traffic; it should not try to authenticate, proxy, store, or inspect the webmail session.
If the provider changes its login host, update the configured destination and retest both the root shortcut and nested login paths. Do not hardcode a tokenized URL from one user's mailbox into the application.
Validation Checklist
- Query token is preserved.
- No 404 for nested webmail paths.
- No logged token values in server logs.
- MX records remain unchanged.
Need build help for routing and migrations? Contact ValeoFX.
Keep the Thread Going
- Service path: Next.js Migrations
- Related read: Fix SiteGround Webmail 404 on Vercel with Next.js
- Proof point: Aerconic
- Ready to scope your own version? Start a project





