2016-08-17 37 views
0

我正在研究Ember 2.6應用程序,並且在刷新頁面時遇到了麻煩。這看起來是一個常見的問題,所以我已經找到並更新了.htaccess文件如下:Ember和htacess刷新

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> 

所以這個作品,每當我刷新就像一個網址:http://danyuschick.com/projects

但是,它不會加載每當我刷新:http://danyuschick.com/projects/14

這裏是我的路由器:

Router.map(function() { 
    this.route('about'); 
    this.route('blogs'); 
    this.route('projects', function() { 
     this.route('index', { path: '/' }); 
     this.route('project', { path: '/:project_id' }); 
    }); 
    this.route('error', { path: '*path' }); 
    this.route('loading'); 
}); 

而且我的路線定義模型

model(params) { 
    return this.store.findRecord('projects', params.project_id); 
} 

我不知道這個更新需要發生的地方,htaccess或我的路由器或什麼。任何幫助都會很棒。謝謝!

+0

嘗試this.store.findRecord('project',params.project_id); - 默認情況下,ember-data會複製模型和請求數據 – kumkanillam

+0

沒有運氣,@kumkanillam。仍然是在刷新時沒有加載文件或樣式的結果。沒有控制檯錯誤,雖然我可以看到, – Yuschick

+0

雖然我可以告訴刷新時,params.project_id仍然正確填充。 – Yuschick

回答

0

如果你試試這個,它應該工作:

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^(.*) /index.html [NC,L] 

它能做什麼,是檢查的%{REQUEST_FILENAME}是的文件的大小,或者是符號鏈接,或目錄。如果沒有,它會重寫請求index.html

+0

沒有變化。我仍然可以刷新/項目,但不能/項目/ 14。 – Yuschick