How to remove#from Angularjs URL

Asked

Viewed 155 times

0

The URL of my application is like this 'http://localhost/ssga/#/login'. I’m trying to get '#' out of the URL, I’ve tried several ways but I’m not getting it. I have the following code.

config.js:

function config($stateProvider, $urlRouterProvider, $locationProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider) {

// Configure Idle settings
IdleProvider.idle(5); // in seconds
IdleProvider.timeout(120); // in seconds

$urlRouterProvider.otherwise("/login");
// $locationProvider.hashPrefix('');

$ocLazyLoadProvider.config(['$locationProvider', function($locationProvider) {
  $locationProvider.html5Mode(true);
    // Set to true if you want to see what and when is dynamically loaded
    debug: false
}]);

index.html:

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

1 answer

1


This is not possible because the character "#" is part of the Angular routing mechanics.

To "remove" this character, you will have to take the routing to the server side, either using a framework (recommended) or something more "handmade" with the creation of folders on the server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.