THinkPHP 3.1.3 實現二級域名隱性url轉發

字號+ 編輯: 国内TP粉 修訂: 种花家 來源: 张进杰 2023-09-10 我要說兩句(0)

隱性 URL 和顯性 URL 的區別和代碼案例。

顯性 URL 轉發:


例如: http://b.com/ 指向 http://a.com/example/ (任意目錄);當在瀏覽器地址欄中敲入 http://b.com/ 後回車,IE 瀏覽器的地址欄裡顯示的地址會由原來您敲入的 http://b.com/ 自動變爲顯示真正的目標地址 http://a.com/example/


隱性URL 轉發:


例如:http://b.com/ 指向 http://a


隱性 URL 和顯性 URL 的區別


顯性 URL 轉發:


例如: http://b.com/ 指向 http://a.com/example/ (任意目錄);當在瀏覽器地址欄中敲入 http://b.com/ 後回車,IE 瀏覽器的地址欄裡顯示的地址會由原來您敲入的 http://b.com/ 自動變爲顯示真正的目標地址 http://a.com/example/


隱性URL 轉發:


例如:http://b.com/ 指向 http://a.com/example/ (任意目錄);當在瀏覽器地址欄中敲入 http://b.com/ 後回車,IE 瀏覽器的地址欄裡顯示的地址保持不變,仍是 http://b.com/ ,但實際訪問到的是 http://a.com/xxx/ 的内容。


二級域名,例如設置 bbs.xxx.com,可以訪問自動跳轉到 xxx.com/bbs,這樣對於域名訪問,非常直觀和方便。而隱性URL,更加適合美觀和簡短的效果。在二級域名訪問前,需要做二級域名的解析和綁定,最後是在框架入口文档ThinkPHP.php 書寫跳轉代碼,下面是我的ThinkPHP.php的二級域名跳轉代碼


$domain = $_SERVER['HTTP_HOST'];
if ($domain == "xxxx.com") {

echo '<link rel="Shortcut Icon" href="/ask/favicon.ico">';
echo '
        <frameset framespacing="0" border="0" rows="0" frameborder="0"> 
       <frame name="main" src="http://xxxx.com/ask/Index/index.html" scrolling="auto" noresize> 
       </frameset>';

//header("location:http://xxxx.com/ask/Index/index.html");  
} else if ($domain == "xxxx.com") {
// header("location:http://xxxx.com/baike"); 
echo '
       <frameset framespacing="0" border="0" rows="0" frameborder="0"> 
       <frame name="main" src="http://xxxx.com/baike" scrolling="auto" noresize> 
       </frameset>';
} else if ($domain == "hc.3bkstore.com") {
// header("location:http://xxxx.com/hc"); 
//    if($_SERVER['HTTP_HOST'] == $domain){ 
echo '
    <frameset framespacing="0" border="0" rows="0" frameborder="0"> 
    <frame name="main" src="http://xxxx.com/hc" scrolling="auto" noresize> 
    </frameset>';
echo '
    <noframes>  
              <body>  
                  <ul>  
                       您的瀏覽器可能不支持框架頁面.  
                       <li>此頁面爲提供域名的轉向功能,與站點{$target}無關.  
                       <li>如此轉向頁面指向到有害内容,請聯絡<a href="#">域名轉向服務提供商</a>刪除  
                  </ul>  
              </body>  
    </noframes>  
    ';
} else if ($domain == "xxxx.com") {
// header("location:http://xxxx.com/baike"); 
echo '<title>網路聊天室</title>';
echo '<link href="chat/favicon.ico" rel="shortcut icon">';
echo '
       <frameset framespacing="0" border="0" rows="0" frameborder="0"> 
       <frame name="main" src="http://xxxx.com/chat" scrolling="auto" noresize> 
       </frameset>';
} else if ($domain == "case.3bkstore.com") {
// header("location:http://xxxx.com/baike"); 
echo '
       <frameset framespacing="0" border="0" rows="0" frameborder="0"> 
       <frame name="main" src="http://xxxx.com/case/Index/index.html" scrolling="auto" noresize> 
       </frameset>';
}


閲完此文,您的感想如何?
  • 有用

    0

  • 沒用

    0

  • 開心

    0

  • 憤怒

    0

  • 可憐

    0

1.如文章侵犯了您的版權,請發郵件通知本站,該文章將在24小時内刪除;
2.本站標注原創的文章,轉發時煩請注明來源;
3.交流群: 2702237 13835667

相關課文
  • mac開發接入微信公衆號接口返回報錯 cURL error 56: SSLRead() return error -9806

  • PHP的換行符是什麽

  • pecl安裝程序時報錯Array and string offset access syntax with curly braces is no longer supported

  • 由於商家傳入的H5交易參數有誤,該筆交易暫時無法完成,請聯繫商家解決

我要說說
網上賓友點評