概述的「替換」:類型錯誤:無法讀取屬性未定義
我想訪問者重定向默認頁面(的index.html)的目錄結構中,以顯示在目錄使用.htaccess
訪問文件(截至目前當前目錄index.html正在加載)。
但是,當我打開$locationProvider.html5Mode(true)
在我的角度應用程序獲取低於錯誤。
控制檯錯誤:應用程序的
目錄結構:
public_html
--prod
--public
--app
--controllers
--directives
--services
--app.config.js
--index.html
--.htaccess
.htaccess
的public_html=>
的.htaccess:
DirectoryIndex prod/public/index.html
這.htaccess
直接用於使用域名的應用程序頁面(prod/public/index.html
)的訪問者重定向,截至目前,當用戶訪問該域名(public_html
)的index.html加載當前目錄。
的public_html=>
督促=>
的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /prod/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /prod/public/#/$1
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/prod/$1 [L,R=301]
</IfModule>
督促=>
公共=>
的index.html:
<base href="/prod/public/">
一切工作正常如果我從我的app.config.js
文件中刪除$locationProvider.html5Mode(true)
.So,當我註釋掉$locationProvider
代碼時,在#
模式下一切正常工作。我可以到/#/abc
等沒有問題。只要我把$locationProvider
零件放回去,什麼都不會發生。
堆棧溢出相關的問題,但沒有成功:
$locationProvider.html5Mode(true) issues
Angular html5 mode not working in apache
請問你能解釋一下這些行嗎?我想''urls'沒有'#'。 –
我沒有試圖改變你的顯示規則。我發現的主要問題是「DirectoryIndex prod/public/index.html」不正確,不會將域請求重寫爲「/ prod/public/index.html」,因爲「DirectoryIndex」只設置默認處理程序文件。不幸的是,我對angularjs知之甚少,所以我只能在Apache方面提供幫助。測試我的更新規則,看看是否能解決您的問題。 – anubhava
其按預期工作。謝謝 –