Apacheredirect到AngularJs的index.html

我正在构build和部署我的AngularJs应用程序。

文件夹结构如下:

/ /path /path/to /path/to/install /path/to/install/index.html /path/to/install/js /path/to/install/css ... 

我想将所有请求redirect到/path/to/install/index.html,除了请求文件存在。

最初我把我的应用程序放在/ dev中,我的.htaccess放在/ dev里面是:

 Options +FollowSymLinks IndexIgnore */* RewriteEngine on ErrorDocument 404 /dev/index.html # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_URI} !/api RewriteRule ^.*$ - [NC,L] # otherwise forward it to index.html #RewriteRule ^.*$ - [NC,L] RewriteRule ^/(.*) /dev/$1 [NC,L] 

它工作正常。 然而,当我打算把它放在/ path / to / install中,并在.htaccess中更改'/ dev'时,服务器总是给我500内部服务器错误,即使我input:

 www.mysite.com/path/to/install/index.html 

当我在/ path / to / install /中删除.htaccess时,500错误消失了。 我试图把.htaccess放在/path等,并试图在.htaccess几个不同的path设置,但仍然无法解决它。

当我把.htaccess放在/ path / to / install时:我发现如果.htaccess包含:

 Options +FollowSymLinks 

只有,没有500错误,但如果.htaccess conatins:

 Options +FollowSymLinks IndexIgnore */* 

要么

 Options +FollowSymLinks RewriteEngine on 

这两个给我500。

我不确定它是否提供了有关问题的线索。 如何解决?

这是由于.htaccess错误的行分隔符格式。 使用文本编辑器将格式更改为其他格式(CRLF / LF / CR)将解决问题。