how to redirect non www to www using javascript

<script type=”text/javascript”>
if ( document.domain.substring(0,4).toLowerCase() != ‘www.’ ) {
window.location = document.URL.replace(“//”,“//www.”);
}
</script>

Leave a Comment