0

Hi I am using Angular JS for my Front End, php is the Service layer.

I am trying to remove the # from my url.

Now : http://localhost/loginwithangular/#/login

I want look like : http://localhost/loginwithangular/login

I tried : $locationProvider.html5Mode(true);but it is not working.

Could you please some one suggest how to make it work.

Thanks in advance !

9
  • 1
    add this to inside your <base href="/" /> inside <head></head> tag Commented Nov 26, 2016 at 10:45
  • 1
    i have already use <base href="/" /> inside <head></head> tag.but still not work properly. Commented Nov 26, 2016 at 10:48
  • 1
    http://localhost/loginwithangular is this you base URL ? i mean your whole website running inside the http://localhost/loginwithangular ? Commented Nov 26, 2016 at 10:50
  • 1
    ohk i will try it Commented Nov 26, 2016 at 10:54
  • 1
    if yes then try adding this code <base href="/loginwithangular/index.html" /> or <base href="/loginwithangular/" /> Commented Nov 26, 2016 at 10:55

3 Answers 3

1

try this

angular.module('phonecat', []).
 config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {

$routeProvider.
  when('/phones', {templateUrl: 'partials/phone-list.html',   controller: PhoneListCtrl}).
  when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}).
  otherwise({redirectTo: '/phones'});

$locationProvider.html5Mode(true);

 }]);
Sign up to request clarification or add additional context in comments.

1 Comment

i have already use $locationProvider.html5Mode(true); in my app.js ;but still does not work properly.
1

You need to add the <base href='/'> in your index.html also in your app.js you need to add

$locationProvider.html5Mode({
      enabled: true,
      requireBase: true
    });

Comments

1

You have to add RewriteBase / in your

.htaccess

file. and add <base href="/"> in your

index.html

file and also add $locationProvider.html5Mode(true) to your

main.js

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.