How I Fixed Ahrefs 3xx redirects in sitemap (www vs non-www on Cloudflare DNS + Vercel)

Technical SEOSeptember 19, 20268 min read

I bought brightjasper.com on September 16 and ran an Ahrefs audit the next day. The health score was 33%. There were 55 errors. Almost half were 308 redirects. Ahrefs kept reporting "3xx redirect in sitemap."

Why does Ahrefs show 308 instead of 301?

Ahrefs shows 308 because that's what Vercel uses by default. Both 301 and 308 are permanent redirects, but 308 preserves the request method (POST stays POST). For SEO, both pass the same link equity. Vercel and Next.js use 308 for a reason, so there was no need to replace it with a 301.

What was the actual problem?

I had four versions of the domain competing with each other:

  • http://brightjasper.com
  • http://www.brightjasper.com
  • https://www.brightjasper.com
  • https://brightjasper.com

The sitemap used one version, the canonical used another, and Ahrefs was set to crawl a third. The result was a site that kept redirecting requests instead of giving every URL one clear, final home.

What was my setup?

Cloudflare was set to DNS-only (grey cloud, not orange). That meant Cloudflare was not proxying traffic. If you have Cloudflare set to proxy, see the last section for your version of the fix.

Vercel handles HTTP-to-HTTPS redirects by default, so I did not need to add an HTTPS rule in Cloudflare. That is also why I did not add a separate www redirect in Cloudflare — with DNS-only Cloudflare and Vercel handling the domain, adding another redirect layer would risk a loop: Cloudflare -> Vercel -> Cloudflare.

How did I fix it?

Step 1: Pick one domain and commit to it

I chose https://brightjasper.com (HTTPS and non-www).

In Vercel, open Dashboard > Your Project > Settings > Domains.

Set brightjasper.com as the primary domain. Add www.brightjasper.com and set it to redirect to brightjasper.com.

Vercel handles the 308 automatically. You don't need a vercel.json file, but an explicit redirect would look like this:

{
  "redirects": [
    {
      "source": "/(.*)",
      "has": [{ "type": "host", "value": "www.brightjasper.com" }],
      "destination": "https://brightjasper.com/$1",
      "permanent": true
    }
  ]
}

permanent: true produces a 308 in Vercel. Leave it alone.

Step 2: Fix the canonical in Next.js

This was the part causing the most damage. Every page was canonicalizing to /.

In app/layout.tsx or lib/metadata.ts, set the site-wide base URL:

export const metadataBase = new URL("https://brightjasper.com");

Then give each page its own canonical path:

export const metadata = {
  alternates: {
    canonical: "/blog/how-i-fixed-ahrefs-308-redirect",
  },
};

For dynamic pages, build the canonical from the current slug. Check the generated HTML and confirm a post contains:

<link
  rel="canonical"
  href="https://brightjasper.com/blog/how-i-fixed-ahrefs-308-redirect"
/>

It should not contain the homepage URL on every page.

Step 3: Fix the sitemap

Your sitemap should use the same version of every URL: HTTPS, non-www, with no accidental homepage canonical.

In an App Router project:

export default function sitemap() {
  return [
    { url: "https://brightjasper.com", lastModified: new Date() },
    {
      url: "https://brightjasper.com/blog/how-i-fixed-ahrefs-308-redirect",
      lastModified: new Date(),
    },
  ];
}

Make sure the sitemap, canonical URLs, and Ahrefs crawl target all use the same domain version.

Step 4: Fix the Ahrefs audit scope

In Ahrefs > Site Audit > Settings, set the project URL to:

https://brightjasper.com/

It should match the sitemap and canonical version exactly. Then rerun the audit.

What was the result?

Before: 33% health and 55 crawl errors.

After: 100% health and 0 errors.

The re-crawl took about four minutes.

What if you use Cloudflare Proxy (orange cloud)?

If your Cloudflare DNS is orange-cloud proxied, Vercel's automatic HTTPS handling is not the whole setup. In that case:

  1. Go to Cloudflare > SSL/TLS and set the mode to Full, not Flexible.
  2. Create a Rules > Redirect Rule that sends www.brightjasper.com to https://brightjasper.com.
  3. Enable SSL > Edge Certificates > Always Use HTTPS.

But if your DNS is grey-cloud DNS-only, do not add those proxy rules. Let Vercel handle the redirect. Two systems trying to redirect the same request can create a loop.

Conclusion

The 308 redirects were not the real SEO problem. The real problem was that the sitemap, canonical URLs, domain settings, and Ahrefs crawl target were not all pointing to the same version of the site.

Choose one canonical domain, let one system handle redirects, and make every SEO signal agree with that choice. Once I used https://brightjasper.com consistently, Ahrefs could crawl the site properly, the health score reached 100%, and the "3xx redirects in sitemap" error disappeared.


Stack: Cloudflare DNS-only, Vercel, Next.js 14, and Ahrefs.