If URL Contains a Specific Port Redirect With JavaScript -


i need redirect url such http://forum.domain.com:4567 https://forum.domain.com. code run site wide, must redirect when visitor goes http://forum.domain.com:4567

i have tried this, loops:

<script>     if (window.location.href = "http://forum.domain.com:4567") {         window.location = "https://forum.domain.com";        } </script> 

window.location location type, similar url type, meaning should have port property.

you can like:

if (window.location.port === "4567"){     window.location = "https://forum.domain.com"; } 

or in case want little more extensibility:

if (window.location.port === "4567"){     window.location = window.location.href.replace(':' + window.location.port, ""); } 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -