3

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.

phisshion
  • 29
  • 3

2 Answers2

4

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]
Patsy Issa
  • 11,113
  • 4
  • 55
  • 74
0

If you can back to hash, you can change the locationType setting it to "hash".

Check it out the next answer: https://stackoverflow.com/a/28630973/4425050

I had the same problem and I fixed it with that.

Community
  • 1
  • 1
Vinicio Ajuchan
  • 342
  • 1
  • 9
  • Using HistoryLocation where available is more like the ember way to do it, so, while this should work under normal circumstances, I'd recommend Kitler's solution. – jnfingerle Apr 16 '15 at 15:04