【问题标题】:Problem when my React App is put on the web将我的 React 应用程序放到网络上时出现问题
【发布时间】:2019-09-15 05:59:27
【问题描述】:

我已经创建了我的 React 应用程序,npm run build ... 将我的文件放入 filezilla, 但问题是我有这个错误

Not Found
The requested URL /main was not found on this server.

当我转到https://clickswinner.alwaysdata.net以外的页面时

你有什么建议?

【问题讨论】:

  • 没有任何代码的人应该如何知道如何提供帮助?通常,该错误意味着未在服务器上定义路由。
  • 这个链接看起来很垃圾,不要指望很多人点击它来提供帮助。相反,请为相关路由提交您的服务器代码。
  • 是的,但它可以在本地工作。你想要代码的哪一部分?
  • @Matt0o: 你能分享你托管文件的服务器名称吗...
  • @HolyMoly alwaysdata alwaysdata.com

标签: javascript reactjs production filezilla


【解决方案1】:

尝试创建一个 .htaccess 文件并将其放在服务器的根目录

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.html [L]
</IfModule>

【讨论】:

  • 感谢 乐于助人 :)
【解决方案2】:

Google 是你的朋友

这是一篇关于如何修复 Filezilla 的 404 问题的文章 https://medium.com/@christine_tran/deploying-a-simple-react-application-using-ftp-filezilla-dreamhost-1e5ff6b8abd6

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-22
    • 2020-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多