Netlify redirects
How do you guys manage redirects in Netlify? I was reading the article but just didn't stick to me.
https://docs.netlify.com/routing/redirects/
I made a file like it says in here (a
_redirects
file), but nothing really changed :(Redirects and rewrites
Manage traffic to your site by defining redirect or rewrite rules in a _redirects file or a netlify.toml file.
44 Replies
is it in the root of your publish dir?
That's what I'm wondering as well.
Should be sitting next to something like
robots.txt
?
Or in my public?
In this case I'm using Astro.base build folder (if that is public then yes)
I have not used Astro recently I remember it building to Public though so probably
Now that I'm seeing it, Astro didn't pick it up from
src
.
So I guess it should be in public
.yea so its not getting included in the build step
Let me try then.
yea can also tell Vite to include it.
Astro uses Vite, right (to confirm)?
(as builder)
yes Astro is essentially just a Vite plugin
without it we would have no Astro š (well not true Fred started it with his bundler Snowpack... which is lots like Vite)
SvelteKit is as well, they actually removed the abstraction and ARE a plugin for Vite. This really makes it nice imo to configure things.
How can I check if Netlify has access to it?
Wind Cutter Guide
Comprehensive, concise and dynamic Ragnarok Online guide.
Is there any way by looking at the dev tools?
na cause its an internally used file shouldnt be served to the client.
I'm still rather unexperienced in Netlify lemmi look at mine
They mention a
netlify.toml
but I don't understand how to configure it.
It's under functions.Yea that is another way
but I think you would have the same issue cause it needs to be in the root š¤
oh no you can set its dir in admin
This is the root, right?
Yes that is root
This is after I ran
npm run build
.yea should be the right spot, ship it
Yeah I did, that's the live me try something.
This is the one I want it to redirect.
https://cozynova.online/hackandslasher/
Wind Cutter Guide
Comprehensive, concise and dynamic Ragnarok Online guide.
And this is what I have in the file.
Unless I need to specify... even further?
Can I ask why the redirect?
I need to change the name of it.
As the guide was used in the community, some people will know it as /windcutter instead.
So I don't want to leave them with a 404 š
ok its perfect case for 302 redirect just checking
oh sry 301 (is perm)
>.>;;
Yeah š
Don't worry I did some research before asking.
I just couldn't get it to work as I wanted.
Yea so looks like you would want the TOML probably
cause that lets you set the response code too
Stack Overflow
How to make 301 redirect in Netlify work?
I can't get the 301 redirect to work in Netlify at all (I've seen other answers, but it doesn't work).
I've made the _redirects file and placed it in the root of my github ripo.
https://zen-booth-...
So kind of the same logic as
_redirects
.They were putting the _redirect in the project root š¤. Either way looks like proper way would be the TOML
From what I'm understanding.
yea
oh I noticed you linked with a trailing slash
are you linking them with trailing slash??
I was following the page's example:
It looked simple enough.
that is the _redirect file though. I would try the toml
simple cause it lets you define the status code
Yeh, I will use
.toml
now, or rather, try.Wind Cutter Guide
Comprehensive, concise and dynamic Ragnarok Online guide.
Mind trying it to see if it works?
works
š
Great, thanks!
Case closed š¤
welcome