【问题标题】:How to deploy Create React App to Hostinger?如何将 Create React App 部署到 Hostinger?
【发布时间】:2021-09-01 11:37:55
【问题描述】:

我在查看我部署到 Hostinger 根文件夹或等效(子域)的网站子页面时遇到问题,我运行“npm run build”并将“build”文件夹中的文件部署到托管程序。

当然,它适用于我的本地和 firebase,但不适用于 Hostinger。

有关主页、内页和 FTP 内容,请参阅下面的文件。

家:

子页面:

“build”文件夹中的 ftp 内容。

谢谢!

【问题讨论】:

    标签: hosting create-react-app web-hosting


    【解决方案1】:

    我知道这是步骤:

    1. 在您的“public”文件夹中创建 .htaccess 并粘贴 ff 代码。

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteRule . /index.html [L]
    </IfModule>
    1. 使用以下命令构建应用程序。

      npm run build 或 yarn build

    2. 并将您的“构建”文件夹部署到您的根文件夹或等效(子域)。

    就是这样,它对我有用。

    【讨论】:

      猜你喜欢
      • 2017-09-21
      • 2018-10-19
      • 1970-01-01
      • 2019-06-05
      • 2018-09-06
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 2022-01-06
      相关资源
      最近更新 更多