So I want to be able to redirect site's port only since I'm running the website as 3 different types of IPS. So on WebServer hosting device I've edited the host file 127.0.0.1
to q
. So on host device I can access my website as q:8080
. On internal devices I can access it as 192.168.43.1:8080
and I've port forwarded version.I have DNS and changed the external port. So other people can access my site by entering http://ladasno.hopto.org:8080
. So the reason I'm asking this because I pretty lack knowledge yet. So I want for each address to be redirected from 8080
to 9090
(For Internal ports) and from 80
to 90
for external ports. So what should I do.
So I've tried like looking for a way to read website's url user is accessing from (FAILED TO FIND). Then I've tried to like to make window.location.replace("urls") 4 times at once. Then I used .. since I thought it will autofind the part that has left of the url
So first I just tried:
function redirect() {
window.location.replace("http://q:9090/Page/Index.html");
window.location.replace("http://192.168.43.1:9090/Page/Index.html");
window.location.replace("http://ladasno.hopto.org:9090/Page/Index.html");
}
This has failed since redirects to last URL I've provided. Then I've tried:
function redirect() {
window.location.replace("..:9090/Page/Index.html");
}
And this just shows error in console:
Uncaught DOMException: Failed to execute 'replace' on 'Location': '..:9090/Page/Index.html' is not a valid URL.
at redirect (http://192.168.43.1:8080/:5:21)
at HTMLButtonElement.onclick (http://192.168.43.1:8080/:10:31)
Please HELP ME!
So I have high expectations for stackoverflow community members. And I don't think I can describe actual results because I haven't seen any details.