![](/img/trans.png)
[英]Angular $locationProvider html5Mode / <base> error
[英]Getting 404 error when Angular HTML5Mode is true
我已經在angular中實現了漂亮的URL(切換到html5mode)。
當我刷新頁面時,出現404錯誤。
例如:如果我使用http:// server /打開我的應用程序,一切正常,但是當我引用該頁面或嘗試打開特定頁面(例如http:// server / mypage)時 ,出現404錯誤。
注意:
編譯后,我的腳本(帶有模板)進入構建文件夾,並且index.html中的基本標記設置為“ /”;。
我正在使用Angular-ui-router。
請提出可能的解決方案或錯誤原因。
謝謝
您應該檢查后端的設置,當我使用html5歷史記錄時,為此我有.htaccess文件(您將所有請求重定向到根index.php或index.html文件),請查看我的.htaccess:
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
如果這沒有幫助,您可以閱讀此[文章]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.