Splat redirect not working with Svelte framework (I read the guide)

I have tried everything in the redirects post and still I get a 404 when I try to visit:

https://bars.raptorsrepublic.com/game/0022101021/plus-minus

The logs saw that the redirect rule was processed. I’ve also tried copying the _redirects file to multiple places but no luck.

Site name: vigorous-kilby-08b0d8

Deploy log:

vigorous-kilby-08b0d8

_redirects file:

/game/* Bars - Raptors Republic 200!

Build command:

npm run build && cp _redirects public/_redirects && cp _redirects public/build/_redirects

Deploy log:

3:52:24 PM: Build ready to start
3:52:26 PM: build-image version: 195fbe127e5c374d9c4758652cb62e3b8936a395 (focal)
3:52:26 PM: build-image tag: v4.6.0
3:52:26 PM: buildbot version: 4ac77ee15240cafa5a14a04b6ca18d8959fa98e6
3:52:26 PM: Fetching cached dependencies
3:52:26 PM: Starting to download cache of 155.7MB
3:52:30 PM: Finished downloading cache in 4.369665136s
3:52:30 PM: Starting to extract cache
3:52:34 PM: Finished extracting cache in 3.989648604s
3:52:34 PM: Finished fetching cache in 8.374417376s
3:52:34 PM: Starting to prepare the repo for build
3:52:34 PM: Preparing Git Reference refs/heads/main
3:52:34 PM: Parsing package.json dependencies
3:52:35 PM: Starting build script
3:52:35 PM: Installing dependencies
3:52:36 PM: Python version set to 2.7
3:52:36 PM: Started restoring cached node version
3:52:37 PM: Finished restoring cached node version
3:52:37 PM: v16.14.2 is already installed.
3:52:38 PM: Now using node v16.14.2 (npm v8.5.0)
3:52:38 PM: Started restoring cached build plugins
3:52:38 PM: Finished restoring cached build plugins
3:52:38 PM: Attempting ruby version 2.7.2, read from environment
3:52:39 PM: Using ruby version 2.7.2
3:52:39 PM: Using PHP version 8.0
3:52:39 PM: Started restoring cached node modules
3:52:39 PM: Finished restoring cached node modules
3:52:39 PM: Started restoring cached go cache
3:52:39 PM: Finished restoring cached go cache
3:52:39 PM: go version go1.16.5 linux/amd64
3:52:39 PM: go version go1.16.5 linux/amd64
3:52:39 PM: Installing missing commands
3:52:39 PM: Verify run directory
3:52:41 PM: ​
3:52:41 PM: ────────────────────────────────────────────────────────────────
3:52:41 PM: Netlify Build
3:52:41 PM: ────────────────────────────────────────────────────────────────
3:52:41 PM: ​
3:52:41 PM: ❯ Version
3:52:41 PM: @netlify/build 26.5.0
3:52:41 PM: ​
3:52:41 PM: ❯ Flags
3:52:41 PM: baseRelDir: true
3:52:41 PM: buildId: 6238d7789c48fc000841548b
3:52:41 PM: deployId: 6238d7789c48fc000841548d
3:52:41 PM: ​
3:52:41 PM: ❯ Current directory
3:52:41 PM: /opt/build/repo
3:52:41 PM: ​
3:52:41 PM: ❯ Config file
3:52:41 PM: No config file was defined: using default values.
3:52:41 PM: ​
3:52:41 PM: ❯ Context
3:52:41 PM: production
3:52:41 PM: ​
3:52:41 PM: ────────────────────────────────────────────────────────────────
3:52:41 PM: 1. Build command from Netlify app
3:52:41 PM: ────────────────────────────────────────────────────────────────
3:52:41 PM: ​
3:52:41 PM: $ npm run build && cp _redirects public/_redirects && cp _redirects public/build/_redirects
3:52:41 PM: > svelte-app@1.0.0 build
3:52:41 PM: > rollup -c
3:52:41 PM:
3:52:41 PM: src/main.ts β†’ public/build/bundle.js…
3:52:48 PM: created public/build/bundle.js in 6.5s
3:52:48 PM: ​
3:52:48 PM: (build.command completed in 7.5s)
3:52:48 PM: ​
3:52:48 PM: Creating deploy upload records
3:52:48 PM: ────────────────────────────────────────────────────────────────
3:52:48 PM: 2. Deploy site
3:52:48 PM: ────────────────────────────────────────────────────────────────
3:52:48 PM: ​
3:52:48 PM: Starting to deploy site from β€˜public’
3:52:48 PM: Creating deploy tree
3:52:48 PM: 1 new files to upload
3:52:48 PM: 0 new functions to upload
3:52:49 PM: Site deploy was successfully initiated
3:52:49 PM: ​
3:52:49 PM: (Deploy site completed in 658ms)
3:52:49 PM: ​
3:52:49 PM: ────────────────────────────────────────────────────────────────
3:52:49 PM: Starting post processing
3:52:49 PM: Netlify Build Complete
3:52:49 PM: ────────────────────────────────────────────────────────────────
3:52:49 PM: ​
3:52:49 PM: (Netlify Build completed in 8.2s)
3:52:49 PM: Post processing - HTML
3:52:49 PM: Caching artifacts
3:52:49 PM: Started saving node modules
3:52:49 PM: Finished saving node modules
3:52:49 PM: Started saving build plugins
3:52:49 PM: Finished saving build plugins
3:52:49 PM: Started saving pip cache
3:52:49 PM: Finished saving pip cache
3:52:49 PM: Started saving emacs cask dependencies
3:52:49 PM: Finished saving emacs cask dependencies
3:52:49 PM: Post processing - header rules
3:52:49 PM: Started saving maven dependencies
3:52:49 PM: Finished saving maven dependencies
3:52:49 PM: Started saving boot dependencies
3:52:49 PM: Finished saving boot dependencies
3:52:49 PM: Post processing - redirect rules
3:52:49 PM: Started saving rust rustup cache
3:52:49 PM: Finished saving rust rustup cache
3:52:49 PM: Started saving go dependencies
3:52:49 PM: Finished saving go dependencies
3:52:49 PM: Build script success
3:52:50 PM: Post processing done
3:52:52 PM: Site is live :sparkles:
3:53:10 PM: Finished processing build request in 44.905539648s

Hey @Arsenalist

Can you show the contents on the _redirects file you are using?

Hi @coelmay - I have that pasted in the original post. Here it is:

/game/* Bars - Raptors Republic 200!

Apologies, I did see it (a little post formatting goes a long way to help readability :slight_smile:)

Have you tried building locally to test the _redirects file is present in the output directory (given you have tried to copy it to various locations)?

Have you also tried downloading the deployed files to check the contents of the _redirects file? Is it possible the file you are copying isn’t deployed and that Svelte is generating a redirect rule that is processed (and your rule isn’t)?

Additionally, if this is an SPA, the redirect you are likely requiring is

/*   /index.html   200

as found in

1 Like

Amazing! That worked and it totally makes sense! Thank you.