I am currently working on a website where the URL structure is sitename.com/path1/path2. I am looking to use AngularJS to change path1 dynamically. While I have successfully implemented functionality to update path2 using $location.path function, I am unsure about how to modify a specific part of the URL or set an absolute URL. It seems that $location.path and $location.url only allow for changing the last parameter in the URL. Any suggestions on how to achieve this would be greatly appreciated.