2

I have a symfony application which works in a subdirectory:

www.example.com/subdirectory

At this point my application is routed client side with angularjs-framework:

app.config(["$routeProvider", function($routeProvider) {
    $routeProvider.
        when('/', {
            redirectTo: '/homepage'
        }).
        when('/homepage', {
            templateUrl: 'index1.html',
            controller: 'HomepageCtrl'
        }).
        when('/contact', {
            templateUrl: 'index2.html',
            controller: 'ContactCtrl'
        }).
        otherwise({
            redirectTo: '/homepage'
        });
}]);

When the site is loaded:

www.example.com/subdirectory

it automatically changes to:

www.example.com/subdirectory#/homepage

But it should be

www.example.com/subdirectory/#homepage

Anybody could help me to get this working?

Thanks and greetings!

1
  • 1
    your understanding is incorrect ... angular uses #/path convention. What you are seeing is correct. Commented Jan 3, 2016 at 20:48

1 Answer 1

3

For changing the base URL of your application you could use <base href="/subdirectory/"> inside your head tag of page.

But as per your $routeProvider setting the remaining part of URL seems OK to me. If you really wanted to change it then you need to replace

/homepage

with

homepage

in config phase of angular.

Sign up to request clarification or add additional context in comments.

2 Comments

ok but when i call "<a href="/categories">" it automatically changes the whole url to "www.example.com/categories"
@Creativecrypter that will get fixed if you add <base href="/subdirectory/"> as I suggested in answer

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.