Unfortunately you cannot access location.hostname since that's within the javascript engine of the browser, not something exposed to other applications.
This script worked for me to navigate to the root of the current website:acSendKeys("^l") --goto address bar
acDelay(25)
acSendKeys("^c") --copy URL
acDelay(25)
url=acGetClipboardText() --get the URL from the clipboard
new_url=string.gsub(url,"([http://|https://]+[A-Za-z0-9.]*/+).*","%1") --strip out only root address
acSetClipboardText(new_url) --save the new URL to the clipboard
acDelay(25)
acSendKeys("^v") --paste the URL in the address bar
acDelay(25)
acSendKeys("{ENTER}") --send Enter key