除了索引之外的路线上的Emberjs应用程序刷新给出404错误

Pra*_*era 6 javascript apache .htaccess http-status-code-404 ember.js

我有一个使用Ember-App-Kit(EAK)提供的入门套件的小型余烬应用程序.我在构建生产AWS EC2实例后上传了dist目录.

我现在面临的问题::

  1. 当我点击根网址时,我可以看到索引页面,当从索引页面中存在的链接转到任何其他路径时,它工作正常并让我转到该页面.当我尝试在该页面上点击刷新时,会出现问题.

首先我认为这是由于权限错误,但它只是单个html文件,js和css正在加载正确.然后想到可能是htaccess问题所以试图插入一个,但之后也没有效果.应用程序源代码的条带化版本驻留在源代码中

用于重定向的.htaccess文件::

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule ^(.*)$ /index.html [L]
Run Code Online (Sandbox Code Playgroud)

Pra*_*era 3

实际上我不知道如何使用 Apache 服务器来做到这一点,所以我安装了 nginx,它使用我在配置文件中提供的重写规则。

server {
        root /var/www/{Your App Directory Path Here};
        index index.html index.htm;
        server_name {Your website URL or IP address here};

        location / {
                try_files $uri $uri/ /index.html?/$request_uri;
        }
}
Run Code Online (Sandbox Code Playgroud)

您可以在这里找到更多讨论:Ember-App-Kit Git Repo Issue 486