Is there a configuration in Github Pages that allows you to redirect everything to index.html for a Single Page App?

后端 未结 6 741
甜味超标
甜味超标 2021-01-17 15:28

I\'m trying to post my SPA app that works fine locally but when I push it to Github Pages, the interior pages don\'t register if you navigate to them directly.

For

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-17 16:26

    Github pages allows you to create a 404.html page that will be shown each time ... there is a 404 error. If http://USER.github.io/PROJECT_NAME/about doesn't exists, it will show your 404.html content with the "not found" url as window.location.

    So, this page can contain a script that redirect to a hashbang style route. eg : react router, even using clean urls (browserHistory) can understand a route like PROJECT_NAME/#/about and will automatically push to PROJECT_NAME/about.

    That's ugly !

提交回复
热议问题