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

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -