【问题标题】:How do I redirect example.com to example.com/#/ using nginx?如何使用 nginx 将 example.com 重定向到 example.com/#/?
【发布时间】:2016-04-05 17:55:24
【问题描述】:

我在我的网络应用程序中使用 Angular Ui-Router。现在我必须使用example.com/#/ 来访问它。如何在 Nginx 中将用户从 example.com 重定向到 example.com/#/

【问题讨论】:

标签: angularjs nginx angular-ui-router


【解决方案1】:

我认为这应该是纯粹的客户端。 您的网络服务器将为引导 Angular 应用程序的用户 index.html 提供服务。
在您的应用程序中,您必须配置从“”和“/”到所需路由的重定向。

下面的这个例子会将用户从example.com重定向到example.com/#/home

  angular
    .module('home', ['ui.router'])
    .config(function ($stateProvider, $urlRouterProvider) {
      $urlRouterProvider.when('', '/home');
      $urlRouterProvider.when('/', '/home');
    });

【讨论】:

  • 谢谢你。这解决了问题。
猜你喜欢
  • 2015-05-21
  • 2020-06-20
  • 2011-02-28
  • 2018-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多