Search code examples
javascriptapache.htaccessember.jshttp-status-code-404

Emberjs application refresh on route other than index gives 404 error


I have a small ember application using the starter kit provided by Ember-App-Kit(EAK). I have uploaded the dist dir after building for production to AWS EC2 instance.

Issues that I am facing as of now::

  1. When I hit the root url, I can see the index page, while going to any other route from links that are present in the index page it works fine and lets me go to that page. The issue issue occurs when I try to hit refresh on the that page itself.

First I thought it is due to permissions error, but it is only single html file and js and css are loading properly. Then thought might be htaccess issue so tried to insert one , but no effects after that also. The striped down version of the application source code resides in Source Code

.htaccess file used for redirection::

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

Solution

  • I actually couldn't fig out how to do it with Apache server, so I installed nginx and it worked with the rewrite rule that I provided inside the config file.

    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;
            }
    }
    

    More discussion you can find here: Ember-App-Kit Git Repo Issue 486