With these it helps You can't do that. The URL with the query string is sent to the server, and the response is placed in the element. Any code that is loaded will know the URL of the current page, not the URL of the code that was added to it. What you can do is to use the callback that occurs when the content has loaded. As you declare it in the same scope as the method starting the load, it has access to the variable:
like below fixes the issue As it is now, the Stores rewrite would also match the url format that the Stockists rewrite is matching. (.*) matches any number of any characters. To fix this, each (.*) should be changed to ([^/]+). That will match any character except a forward slash and also makes sure that there is at least one character.