gpt4 book ai didi

javascript - Emberjs 应用程序刷新索引以外的路由会出现 404 错误

转载 作者:数据小太阳 更新时间:2023-10-29 05:29:56 25 4
gpt4 key购买 nike

我有一个小型的 ember 应用程序,使用 Ember-App-Kit(EAK) 提供的入门工具包.我已经将生产构建后的 dist 目录上传到 AWS EC2 实例。

我目前面临的问题::

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

起初我认为这是由于权限错误,但它只是单个 html 文件并且 js 和 css 正在正确加载。然后认为可能是 htaccess 问题所以尝试插入一个,但之后也没有效果。应用程序源代码的简化版本位于 Source Code

.htaccess 文件用于重定向::

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

最佳答案

我实际上不知道如何使用 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;
}
}

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

关于javascript - Emberjs 应用程序刷新索引以外的路由会出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21751371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com