0

I'm developing a webapp using AngularJS and Laravel.

When I navigate through URL and links in the app everything works fine, but if I type an URL directly in the browser, something strange happens.

For example, If I type http://myapp.dev/#/customers I get redirected to http://myapp.dev/customers#/

Why? What's wrong? Laravel executes "/" route (right) and Angular "/" route (right, again).

Note: I have made a test application similar to the first but without using Laravel and .htaccess (it serves only static HTML) and I haven't this issue, I can access URL directly.

Thank you.

Edit - here the Angular routing code:

var App = angular.module('Factotum', ['ngResource']);

function appRouteConfig($routeProvider) {
    $routeProvider.

    when('/', {
        controller: IndiceController,
        templateUrl: 'v/indice'
    }).
    when('/login', {
        controller: 'AppController',
        templateUrl: 'v/login'
    }).
    when('/logout', {
        controller: 'AppController',
        templateUrl: 'v/login'
    }).
    // ---- Clienti
    when('/clienti', {
        controller: ClientiController,
        templateUrl: 'v/clienti/lista'
    }).
    when('/clienti/nuovo', {
        controller: ClientiController,
        templateUrl: 'v/clienti/nuovo'
    }).
    when('/clienti/modifica/:id', {
        controller: ClientiController,
        templateUrl: 'v/clienti/modifica'
    }).
    // ---- Progetti
    when('/progetti', {
        controller: ProgettiController,
        templateUrl: 'v/progetti/lista'
    }).
    when('/progetti/nuovo', {
        controller: ProgettiController,
        templateUrl: 'v/progetti/nuovo'
    }).
    otherwise({
        redirectTo: '/'
    });
} // factotumRouteConfig

App.config(appRouteConfig);
5
  • Edit: If I browse to myapp.dev/#customers I get redirected to myapp.dev/#/customers (ok) Commented May 19, 2013 at 9:17
  • are you using angular's html5Mode? Commented May 19, 2013 at 9:57
  • 1
    can you show your routing code ? Commented May 19, 2013 at 12:00
  • @user1737909: No, html5Mode is off. Commented May 20, 2013 at 14:19
  • @Reza Do you mean Angular routing code? I've pasted it in the post. Thanks Commented May 20, 2013 at 14:21

1 Answer 1

2

Finally I found the problem. I'm using a free HTML5 template (Charisma by Usman - here a demo: http://usman.it/themes/charisma/), which includes jQuery History plugin. I removed this plugin, along with some initialization code, and now all is working as expected. My fault, I didn't inspect the code carefully.

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.