zoukankan      html  css  js  c++  java
  • 多域名解析到同一网站C的php重定向代码

    在index.php最前面加上以下代码:

    <?php
    if(strpos($_SERVER['HTTP_HOST'],'afish.cnblogs.com')===false){
        #header('Location: http://afish.cnblogs.com/');
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <title>afish.cnblogs.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="keywords" content="afish.cnblogs.com" />
    <meta name="description" content="afish.cnblogs.com" />
    </head>
    <body>
    <iframe width="100%" scrolling="no" height="2800" frameborder="0" src="http://afish.cnblogs.com"></iframe>
    </body>
    </html>';
        exit();
    }
    ?>

    若要实现直接跳转,只需将#header('Location: http://afish.cnblogs.com/');前面的#号去掉即可。

    若要实现点击链接后再跳转,注释header('Location: http://afish.cnblogs.com/');这一句即可。

     网站C页面head头部添加代码:

    <base href="http://afish.cnblogs.com/" target="_parent" />

    打完收工!

  • 相关阅读:
    C语言第0次作业
    C语言博客作业02循环结构
    C语言博客作业04数组
    C语言博客作业03函数
    #C博客作业01分支、顺序结构
    函数
    operation on i may be undefined
    #关于C语言的顺序结构
    关于代码习惯
    VS2019调试的一系列待理解解决问题
  • 原文地址:https://www.cnblogs.com/afish/p/4501708.html
Copyright © 2011-2022 走看看