How to Remove 301 Redirects in Sanity

1 replies
Last updated: Dec 17, 2021
Hi! I pulled out a SEO-report with the links on our site and I see that numerous sites are not indexable, which we would love to fix to get more organic traffic to our site. We see that most of them are due to a redirect 301. How do we remove the redirects in Sanity? From what we can see the original URL and redirect URL are the same.
AI Update

Based on your question, I need to clarify something important: Sanity itself doesn't create or manage 301 redirects - these are handled by your frontend framework or hosting platform, not by Sanity CMS.

Understanding the Issue

If you're seeing 301 redirects where the original URL and redirect URL are the same, this is causing a redirect loop. This configuration exists in your frontend code or hosting settings, not in Sanity. Common places to check:

  1. Frontend framework config files: next.config.js, astro.config.ts, vercel.json, _redirects, etc.
  2. Hosting platform dashboard: Vercel, Netlify, or other hosting providers often have redirect settings
  3. CDN or proxy configurations: Check if you have any reverse proxy or CDN rules

If You're Using Sanity to Store Redirect Data

Some teams use Sanity to store redirect information as structured content, which is then consumed by their frontend. If you've implemented this pattern (described in this guide), here's how to find problematic redirects:

Query your Sanity dataset to find redirects where the source and destination are identical:

*[_type == "redirect" && from.current == to.current]

Then either:

  • Delete these redirect documents in Sanity Studio
  • Update them to have different source and destination values

How to Fix

  1. Identify where redirects are configured - Check your framework's config files first (this is most likely where the issue is)
  2. Search for circular redirects - Look for rules where the source and destination match
  3. Remove or correct those redirect rules
  4. Redeploy your site after making changes

Key Takeaway

Sanity is a content management system that can store redirect data, but your frontend framework or hosting platform actually implements the redirects. The 301 responses are coming from your web server/hosting layer, not from Sanity. You'll need to fix the configuration at that level to resolve the redirect loops affecting your SEO.

You will probably have to ask whomever is in charge of your website frontend - Sanity is a headless CMS, we don't provide any frontend.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?