js 处理浏览器显示地址
输入 www.test.com、www.test.com/home
显示 www.test.com/home/index
<script> window.onload = function () {//浏览器地址处理 if (window.location.pathname.toLowerCase().indexOf("home") == -1) { var pathname = window.location.pathname; pathname = pathname + '/home/index'; pathname = pathname.replace("//", "/") window.open(window.location.origin + pathname, '_self'); } else if (window.location.pathname.toLowerCase().indexOf("index") == -1) { var pathname = window.location.pathname; pathname = pathname + '/index'; pathname = pathname.replace("//", "/") window.open(window.location.origin + pathname, '_self'); } }); </script>