概述的“替换”:类型错误:无法读取属性未定义
我想访问者重定向默认页面(的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
其按预期工作。谢谢 –