【问题标题】:angular.js html5mode page refresh issue [duplicate]angular.js html5mode页面刷新问题[重复]
【发布时间】:2019-01-22 20:36:07
【问题描述】:

我将我的 angular.js 项目转换为 html5mode 一切正常,直到我尝试刷新我的页面。我做了一些研究,发现它与服务器端有关。

我将<base href="/index.html"> 添加到我的 index.html 中,在所有内容之前。

然后将$locationProvider.html5Mode(true).hashPrefix('!'); 添加到我的应用配置中。

正如其他问题中所建议的那样,我将这些行添加到我的 .htaccess 中

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*) /index.html [NC,L]

但我的问题还在继续。

我该怎么办?

【问题讨论】:

    标签: angularjs apache .htaccess ngroute html5mode


    【解决方案1】:

    我的问题已经解决了

    <IfModule mod_rewrite.c>
        Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_URI} !^/$
        RewriteRule (.*) /#!/$1 [NE,L,R=301]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-05
      • 2018-08-26
      • 2021-12-31
      • 1970-01-01
      • 2011-05-13
      • 2017-04-17
      • 1970-01-01
      相关资源
      最近更新 更多