使用htaccess重定向到带有哈希的URL

时间:2016-08-03 04:06:18

标签: angularjs apache .htaccess

我将如何重定向我的网址...让我们说我输入了网址..

example.com/register

应将其重定向到

example.com/#/register

这可能吗?

1 个答案:

答案 0 :(得分:0)

默认情况下,AngularJs使用$routeprovider$stateProvider提供路由功能。您可以在配置中使用这些提供程序。

angular.config(['$stateProvider','$urlRouterProvider',function ($stateProvider,$urlRouterProvider) {    
    $stateProvider
      .state('dashboard', {
        url:'/dashboard',
        abstract:true,  
        templateUrl: 'views/main.html'     
    })
      .state('dashboard.home',{
        url:'/home',
        templateUrl:'views/home.html'       
      })
$urlRouterProvider.otherwise('/');
});