Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember/Ember-Cli Serving through Apache throws 404

I'm running into a problem when I try to serve my ember app through Apache. Because the location is set to "history" and not "hash", Apache is trying to load the magic ember routes which don't exist as files. myapp.com/login throws a 404 because there is no login.html.

I've done a bit of scouring and its surprising that there isn't much on this which leads me to believe that not many people deploy ember apps on apache.

So it's suggested I write Apache URL Rewrite rules, but the one's I have tried don't seem to be working.

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.html [L]

and

Options FollowSymLinks

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

Don't work.

Does anyone have any idea of what to do other than go back to "hash"?

Regards, Clueless person.

like image 832
phisshion Avatar asked Nov 22 '25 01:11

phisshion


1 Answers

You need to route everything to index except the files that exist:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html#$1 [L]
like image 185
Patsy Issa Avatar answered Nov 24 '25 22:11

Patsy Issa