Pretty url with Angularjs/.htaccess

218 Views Asked by At

I've been struggling with this for a week now. I use Anguarjs and I set the html5mode(true) to get rid of the hash sign "#" that you needed in the url before. Everything works fine amd my URL logic works with Query Parameters.

www.domain.com/thecurrentpage/?title=banana

And it changes and refresh the page when I click on something else and then it displays the right content.

I just want to be able to have a link like:

www.domain.com/thecurrentpage/banana

And come to the same page. That actually will point you to the first one with query params. I feels like I've tried everything in the .htaccess file with rewrite rules and everything with angular routing. I just don't get it.

1

There are 1 best solutions below

2
danday74 On

you want to use the : syntax in your routing.

In your routing add a route like this:

/thecurrentpage/:title

Then you can use:

$routeParams.title

To get the value "banana"

This might help ... AngularJS: Read route param from within controller