search

Home  >  Q&A  >  body text

PHP newbie, please tell me how to jump to a web page based on the domain name?

3 top-level domain names

www.123.com

www.pass.cn

www.sohu.cn


Different domain names, I want to automatically go to different subdirectories.

www.123.com/doc

www.pass.cn/soft

www.sohu .cn/video


Please give me some advice, how to write the PHP code for this homepage?

新疆塔城[HAM]陈新疆塔城[HAM]陈1802 days ago1280

reply all(3)I'll reply

  • 新疆塔城[HAM]陈

    新疆塔城[HAM]陈2020-02-19 14:58:42

    Please give me some guidance.



    reply
    0
  • 排骨

    排骨2020-02-18 08:43:28

    Stupid method

    $_http = $_SERVER['HTTP_HOST'];

    if($_http == 'www.123.com'){

    header("LOCATION:http://www.123.com/doc");

    }elseif($_http == "pass"){

    // Same as above

    }elseif(xxxx){

    //Same as above

    }else{

    echo "Incorrect address input";

    }

    reply
    0
  • 新疆塔城[HAM]陈

    Thanks for the answer, Paigu, I am a real novice, it is my first time to come into contact with this stuff. Can you provide the complete PHP file code? Copy the above code and when browsing, an error message appears.

    新疆塔城[HAM]陈 · 2020-02-19 14:55:14
  • Cancelreply