網站開發中,我們經常需要使用鏈接跳轉,比如登錄成功后,自動跳轉到首頁等等,下面方面介紹 PHP & JS 的幾種鏈接跳轉方式
PHP
<?php header("Location: https://www.ryanzoe.top/");
JS
<script> window.location = 'https://newurl.com' </script>
如果想要跳轉到同一個網站的不同路徑下,可以使用下面的方式
<script> window.location.pathname = '/new' </script>