簡體   English   中英

在EmberJS分發應用中直接訪問路由時出現錯誤404

[英]Error 404 when directly access to a route in EmberJS distribution app

我已經使用EmberJS開發了一個Web應用程序,並且希望在真實服務器中進行部署。

當我在localhost上使用環境開發和命令ember s測試時,一切正常,但是當我使用ember build --environment=production創建分發程序包並使用Web服務器(在我的情況下為python -m SimpleHTTPServer 4200並使用Apache服務器)嘗試直接訪問路由時出現以下錯誤。

Error response

Error code 404.

Message: File not found.

Error code explanation: 404 = Nothing matches the given URI.

如果我輸入myaddress:4200並通過鏈接導航,那沒有什么錯,但是如果我想刷新Web或更改URL,則會發生錯誤404。

在檢查了問題Python SimpleHTTPServer和ember存儲庫中的一個問題之后,我實現的解決方案是通過Apache服務器進行部署並創建一個.htaccess文件,該文件將流量重定向到index.html

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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM