preact-boilerplate icon indicating copy to clipboard operation
preact-boilerplate copied to clipboard

404 \ Page not found when deploying to Netlify

Open zouhir opened this issue 8 years ago • 15 comments

I'm not sure if other static site servers / platforms are all like that, but if we deploy this to Netlify we can only navigate from index.html to other pages using Links, once your refresh or type a URL directly in the address bar we'll get 404

In order to get History push state to work we need to add this re-write rule:

/*    /index.html   200

which can be in a file for Netlify in the repo root.

Can we add this directly? as I can see Netlify support is welcome in the Preact repo.

zouhir avatar Jan 07 '17 04:01 zouhir

Sure! Any chance there's a way to define that in the .toml file? If not then a separate does file is fine.

developit avatar Jan 07 '17 04:01 developit

Unfortunately no. Netlify does in in 1 way only, which is having a _redirects file in the deployed folder eg dist/ but I'll have to update the docs accordingly

zouhir avatar Jan 07 '17 04:01 zouhir

Ref: (https://www.netlify.com/docs/redirects/)[https://www.netlify.com/docs/redirects/]

Looking more into this...

zouhir avatar Jan 07 '17 04:01 zouhir

I think we decided to punt on this for now, right?

developit avatar Jan 07 '17 23:01 developit

I think it's very good to have and won't harm if people won't need it! if ytou think so too, here's a PR https://github.com/developit/preact-boilerplate/pull/103

zouhir avatar Jan 08 '17 00:01 zouhir

I think people need this. I had to go through a lot of pain to get to understand how to use this. It is really helpful especially for situations where you decide to use routers from you js application

pensebien avatar Jul 11 '17 16:07 pensebien

Can anyone help me with this problem "PAGE NOT FOUND. Looks like you've followed a broken link or entered a URL that doesn't exist on this site." I really don't know what to do. My folder came from hithub and when I'm finish deploying it in netlify, when I view my site, It goes like this. capture

ianskie1234 avatar Nov 22 '17 06:11 ianskie1234

You need to configure the fallback HTML page. You can do this by simply copying dist/index.html to dist/200.html and redeploying.

developit avatar Dec 07 '17 17:12 developit

actually i have the same problem, anybody can say exactly what i should do. Thanks

douchuis avatar Mar 14 '19 12:03 douchuis

in my case, for create-react-app:

  • create a _redirects file in public
  • add /* /index.html 200 to that file

constantinpojoga avatar Jun 04 '19 20:06 constantinpojoga

but how I had the same problem and it solved but could you please explain what is the reason behind it?

yash-jp avatar Jan 04 '20 07:01 yash-jp

i have the same problem please help

mikesagini avatar Jan 09 '20 08:01 mikesagini

i have the same problem please help

same :/

haroldao avatar Jan 22 '20 22:01 haroldao

I think, my situation is there isn't the index.html page. so that why the server doesn't know which page to take. So to solve the problem, try to put an index.html page.

Le mer. 22 janv. 2020 à 23:17, Harold ARABA [email protected] a écrit :

i have the same problem please help

same :/

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/developit/preact-boilerplate/issues/101?email_source=notifications&email_token=AKBZXYY7SQJFVGATJRROC33Q7DAYLA5CNFSM4C3VKEGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJVJZOA#issuecomment-577412280, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKBZXYYZFPHNK2EFOWOS7ATQ7DAYLANCNFSM4C3VKEGA .

douchuis avatar Jan 22 '20 23:01 douchuis

in my case, for create-react-app:

  • create a _redirects file in public
  • add /* /index.html 200 to that file

thanks man! it worked for me

mayank0307 avatar Apr 21 '20 06:04 mayank0307