What Is a Redirect and How Do I Add One to My App?
You built something with Claude, ChatGPT, Cursor, or Bolt and you need to send users from one URL to another automatically. Maybe you changed the URL of a page…
You built something with Claude, ChatGPT, Cursor, or Bolt and you need to send users from one URL to another automatically. Maybe you changed the URL of a page and old links are now broken. Maybe you want people who visit yourapp.com to be sent to yourapp.com/dashboard when they are logged in. Maybe you moved content and want the old address to forward to the new one. All of these are redirects. Here is what they are and exactly how to add them.
What a Redirect Actually Is
A redirect is an instruction that tells a browser “the content you are looking for is not here anymore. Go to this other URL instead.” The browser follows the instruction automatically and the user ends up at the right destination, often without noticing anything happened.
A one-sentence definition: a redirect automatically sends users from one URL to another, either permanently or temporarily.
You interact with redirects constantly without realising it. When you type a URL without www and the browser adds it automatically, that is a redirect. When a website moves from HTTP to HTTPS and your bookmark still works, that is a redirect. When you click a shortened link and end up at a long URL, that is a redirect.
The Two Types of Redirects
301 Permanent Redirect: tells browsers and search engines that the content has moved permanently to the new URL. Search engines transfer the ranking and reputation of the old URL to the new one. Use this when you are permanently changing a URL, like renaming a page or moving content.
302 Temporary Redirect: tells browsers the content is temporarily at a different URL but may return. Search engines do not transfer ranking. Use this for temporary situations, like sending users to a maintenance page or seasonally promoting something.
For most situations, 301 is what you want.
Common Situations Where You Need Redirects
Logged-in users should go to the dashboard. When someone visits your homepage while already logged in, redirect them straight to their dashboard instead of showing the marketing page.
A page URL changed. You renamed /about-us to /about. Old links and bookmarks to /about-us should redirect to /about.
Removing trailing slashes. yourapp.com/page/ and yourapp.com/page should be the same page. A redirect from one to the other prevents duplicate content.
Forcing HTTPS. Any HTTP request should redirect to HTTPS. Your hosting platform usually handles this automatically.
How to Add Redirects
On Vercel: create or edit a vercel.json file in your project root and add a redirects section:
json
{
"redirects": [
{ "source": "/about-us", "destination": "/about", "permanent": true }
]
}
On Netlify: create a _redirects file in your publish directory:
/about-us /about 301
In code (for logged-in redirects): ask your AI: “Can you add logic to my app so that when a logged-in user visits the homepage, they are automatically redirected to /dashboard?”
For general redirects in your backend: ask your AI: “Can you add a redirect in my app from [old URL] to [new URL] with a 301 status code?”
Testing Redirects
After adding a redirect, test it by visiting the old URL and confirming you land at the new one. For Vercel and Netlify redirects, you need to deploy first before they take effect.
Use a browser extension like Redirect Path for Chrome to see exactly what redirects are happening for any URL.
The One Thing to Remember
A redirect automatically sends visitors from one URL to another. Use 301 for permanent moves, 302 for temporary ones. On Vercel, use vercel.json. On Netlify, use a _redirects file. For behaviour-based redirects like sending logged-in users to their dashboard, ask your AI to add the logic to your app code.
Want your app running with reliable URL management? → Snapdock
New here? These might help: What is a URL? And how does my app get its own? → How do I connect a custom domain to my app? →