2

The problem is: I cannot reach home page when url is www.some.com but can when it's www.some.com/#! or www.some.com/#!/

I was define default web app route:

$routeProvider.when('', {templateUrl: pathToIncs + 'home.html', controller: 'homeController'});
$routeProvider.when('/', {templateUrl: pathToIncs + 'home.html', controller: 'homeController'});

Added otherwise option:

$routeProvider.otherwise({redirectTo: '/404'});

And turn of html5 mode

$locationProvider.html5Mode(false);
$locationProvider.hashPrefix('!');

As i said befor - it works when I'm came by ulr like www.some.com/#! but not when www.some.com. In this case .otherwise option will be called.

In any other case routing works well. In the my app I got an urls like a www.some.com/#!/login, www.some.com/#!/signup

P.S. Server side works on php5+nginx P.P.S. I'm use Angular 1.2.0 with ngRoute module

1
  • I can try to solve the problem with $routeProvider.otherwise({redirectTo: '/'});. It's will works, but what should I do with 404 errors in this case? Commented Nov 13, 2013 at 3:35

1 Answer 1

2

Try setting the < base > tag.

<head>
  <base href="/">
</head>

Have a route defined for home

.when('/home', {
        templateUrl: pathToIncs + 'home.html', 
        controller: 'homeController'
 })

using redirectTo on the "/"

.when('/', {
    redirectTo: '/home'
})

along with the .otherwise

.otherwise({
    redirectTo: '/home'
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.