Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(netlify): clarify placement of _redirects file #870

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/2.deploy/providers/netlify.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For new sites, Netlify will detect that you are using Nitro and set the publish

If you are upgrading an existing site you should check these and update them if needed.

If you want to add custom redirects, you can do so with [`routeRules`](/config#routerules) or by adding a [`_redirects`](https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file) file.
If you want to add custom redirects, you can do so with [`routeRules`](/config#routerules) or by adding a [`_redirects`](https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file) file to your `public` directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'd suggest to only mention the routeRules here as it is a vendor-independent way for designing redirects which will work even when changing the deploy preset.

Any thoughts @pi0 @danielroe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, routeRules will need a more descriptive documentation. I tried routeRules, but it did not solve the issue I had. I had to use _redirects. Just bringing my thoughts πŸ˜„

Copy link
Contributor Author

@OlaAlsaker OlaAlsaker Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be more precise: in my project, I have a completely separated SPA that lives in the public/admin directory. As with other SPAs, I have to make a redirect rule that work like this:

/admin/*   ->   /admin/index.html

I tried using routeRules for this, but did not succeed. I therefore ended up with the _redirects file as a working solution, but it wasn't clear for me where to put file before I checked the actual source code of Nitro.

Copy link
Member

@pi0 pi0 Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this can be achieved using route rules too. We can keep this as last resort (however consider the file might be overridden!)

Do you mind making a PR @manniL to recommend routeRules?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do ☺️


For deployment, just push to your git repository [as you would normally do for Netlify](https://docs.netlify.com/configure-builds/get-started/).

Expand Down