2015-09-04 57 views
0

我已经在Javascript中写了一个前端SPA。它使用Ember的路由,假的URL,认证和所有惊人的东西Ember几乎隐式处理。告诉Apache总是为index.php服务,不管网址是什么

后端以PHP编写,页面由Apache服务器提供服务。

现在,如果请求被发送到根文件(又名索引)并且从这里处理所有内容,那么该页面工作得很好。如果我可是重装在假设localhost/login页面,阿帕奇试图找到一个文件名为登录,其中,自然不存在,因为一切都在Javascript处理,我得到了广为人知的404 - The requested URL /login was not found on this server.

无论网址中有什么,我如何告诉Apache始终为index.php服务?

回答

2

它应该看起来像Laravel默认的.htaccess,这将永远成为通过/index.php页面的一切,而不在URL前/index.php/login实际/index.php将只是/login,但值得注意的是,这将不会迫使它如果文件存在,则通过/index.php页面。

# Checks if the rewrite mod is on. 
<IfModule mod_rewrite.c> 
    RewriteEngine On 

    # Force everything through the index.php file 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 
相关问题