Safari: Replace part of the URL

Hi all,

Sorry, if this has already been asked, I have tried the search, but after 15 pages I gave up.

I am trying to open a URL with AppleScript. The problem is that the website is linked to a local application and the URL has some sort of session ID in it, i.e. the URL differs every time I open the application.

In my opinion there would be two ways to achieve this:

a) Take the entire URL and replace the page name (i.e. “old.html” with "new.html), which is at the end. Since the page names remain the same, it wouldn’t matter, whether I delete the last 8 characters ("old.html) and attach “new.html” or make something like “search and replace”.

b) Since the URL is the same except the actual page name, I could probably also live with a relative path, but if I just use open location "new.html"
or open location "../new/html"
, it tries to open “http://new.html” instead of using it as a relative path.

I’m sure, the solution is quite simple, but since I’m not really familiar with AppleScript, I have no idea, how to achieve this.

Thanks in advance for any help.