Ember/Ember-Cli Serving through Apache throws 404

随声附和 提交于 2019-12-06 08:17:49

问题


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.


回答1:


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]



回答2:


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.



来源:https://stackoverflow.com/questions/29535283/ember-ember-cli-serving-through-apache-throws-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!