フロントエンドノート(ページの直接リダイレクトは禁止されています。http-equiv= "refresh" Webページは自動的にリダイレクトされます)

1.ダイレクトページjump.jsを禁止する

window.onload=function(){
    
    
    //排除特定页面
    if (this.location.href.indexOf("UI/src/views/home/console.html") > 0 || this.location.href.indexOf("UI/src/views/user/login.html") > 0 ||
        this.location.href.indexOf("UI/src/views/user/forget.html") > 0 || this.location.href.indexOf("UI/src/views/user/forget.html") > 0 || this.location.href.indexOf("UI/src/views/user/reg.html") > 0
        || this.location.href.split("UI/src/views/")[1] == ""
    ) {
    
    
        return;
    }
    //禁止直接页面跳转
    //console.log(this.location.href.split("UI/src/views/")[1]=="");
    if (top.location.href == this.location.href && this.location.href.split("UI/src/views/")[0] != "") {
    
    
        location.replace("../StatePage/IllegalJumpPage.html");
        return;
    }
}


// http://192.168.1.17:8088/UI/src/views/ActivityCenter/CreateActivity.html

効果は次のとおりです。新しいタブで開くか、内部のURLをコピーして実行し、新しく作成されたWebページにアクセスして、直接IllegalJumpPage.htmlにジャンプさせます。

2 META http-equiv = "refresh"を使用して、Webページの自動リダイレクトを実現します

default.htmコンテンツ:

  <meta http-equiv="refresh" content="0; url=UI\src\views\user\login.html" />

環境は次のとおりです。IISプロジェクトフォルダーの下にdefault.htmを作成し、IISの既定のドキュメントの先頭にdefault.htmを配置します。

効果は次のサイトにアクセスすることです:http://192.168.1.19:8063 /自動リダイレクト> http://192.168.1.19:8063/UI/src/views/user/login.html

参照:https://www.cnblogs.com/lixihuan/p/6824871.html

おすすめ

転載: blog.csdn.net/Nightwish5/article/details/109331858