【发布时间】:2016-11-06 07:18:15
【问题描述】:
在我的Angularjs 应用程序中,“#”最初出现在 URL 中。因此,我将应用程序的 HTML5 mode 设置为 true,并在整个应用程序代码中为 URL 进行了必要的更改。 PFB 我的代码。
app.config(function($locationProvider){ $locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
现在根据this link,我在配置文件中进行了必要的更改。这些变化如下:
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /$1 [L]
问题:
应用程序仍然无法运行,它仍然没有刷新 URL,即我仍然收到 404: Page not found 错误。
请帮我解决这个问题。
【问题讨论】:
-
尝试设置
requireBase: true并在 index.html 的标题中插入<base href="/"> -
安德鲁,我做到了。它仍然不起作用。问题似乎出在我在配置文件中编写的重写规则中。我无法弄清楚问题所在。
-
可以肯定的是,您的服务器必须始终发送您的初始 index.html 文件。路由在 angularjs 中处理
标签: angularjs html url-rewriting