You have noticed that whenever you write the URL of an Angular application, a hashtag, i.e /#/, always appear after the application root folder.
For Example: –

It happens because AngularJS is a javascript framework which work at front-end rather than back-end. So, angular adds a hashtag, by default, after the application root folder name.

In this tutorial, we will explain you how to remove hashtag from the routing URL.

Watch the live demo or download code from the link given below.AngularJS Remove Hashtag

To demonstrate this, we are using the same application that we had created in our last blog AngularJS Routing.

In earlier application code,  you have noticed that whenever you run the application through some URL, a hashtag, i.e /#/, will appear in the URL just after the application folder name, which looks ugly.

So, let’s remove this hashtag from the URL and make you URL more beautiful and comfortable to read.

For this, you need to do two changes in the application.
  1. Configure $locationProvider service in the application module.
  2. Add a basetag in head section the application.

Configure $locationProvider

$locationProvider is used to to configure the application module and tell it how to store deep linking path of the application.

It uses html5Mode() method with true as parameter to remove hashtag, i.e /#/, from the URL of the application.

So, let’s apply it in the application and remove hashtag from the URL.

// Applicatio module
var myApp = angular.module('myApp', [

// Configure routing for the application
myApp.config(['$routeProvider','$locationProvider', function($routeProvider, $locationProvider){

// Setting html5Mode as true to remove hashtag
when('/', {
controller : 'EmpListController'
templateUrl : 'templates/emp_list.php',
controller : 'EmpListController'
templateUrl : 'templates/emp_details.php',
controller : 'EmpDetailsController'
{redirectTo : "/"}

Add basetag:

Configuring $locationProvider will remove the hashtag from the application URL but, application will not load correctly. To resolve this, we will have to add a basetag in the head section of  the index page.

<base href=" "/>

The basetag has one property, href. Href contains the URL path upto the application root folder.

For Example:-
Let suppose a URL, 

Here, angularjs is the root folder of the application.

Then, we will write basetag as: –

<base href=""/>

After it, the application will load properly and the application URL will look something like 


Hope you got the concept for this little but very important trick. Apply it in your application and share your feedback with us from the space given below 🙂