【发布时间】:2017-10-19 20:46:22
【问题描述】:
- 我在 IIS 上创建了名为 SA 的虚拟目录,如果键入“Localhost/SA”或“Localhost/Sa/”,一切正常,但如果我键入 URL 不区分大小写,如“Localhost/Sa”,最后没有斜杠,路由失败返回任何页面。
- 如果我禁用了 html5mode,它会得到“404 page not found”页面。 $locationProvider.html5Mode(false);
这是我使用的解决方法:
$urlMatcherFactory.caseInsensitive(true);
$urlMatcherFactory.strictMode(true); // or off nothing is work
$urlRouterProvider.rule(function ($injector, $location) {
var path = $location.path(), normalized = path;//.toLowerCase();
template = path;
if (path !== normalized) {
$location.replace().path(normalized);
}
}
});
- 尝试通过添加 $urlRouterProvider.rule 将“/”连接到 URL 的末尾,但它也不起作用,并且无法在角引导之前将“/”连接到 URL 的末尾。
我已经解决了这个问题,请帮忙。
【问题讨论】:
标签: javascript angularjs asp.net-mvc-5 angular-ui-router