Home  >  Q&A  >  body text

How to do multi-site management in TP (multiple websites correspond to one backend), who has done it? Can you give me some ideas?

Develop multiple websites, and these websites should be managed by one backend. Can anyone tell me how to do it? Using tp to develop, can any master explain the idea

ᴬ ᴾᵀᴬ ᴾᵀ2348 days ago1559

reply all(2)I'll reply

  • dabour

    dabour2018-04-20 16:30:13

    Add a site id to distinguish different websites

    reply
    0
  • 苒苒

    苒苒2018-04-20 09:04:55

    Give you two methods:

    1. Each website corresponds to different entry files

    Thought: In the tp framework, the entry files for the backend and the frontend are admin.php and index respectively. php, then according to this idea, if there are multiple websites, you can create a new entry file such as index2.php, corresponding to the directory of this website, such as: application/Innde2 directory, and then point the project directory to the root directory index2 when setting the domain name .php will do.

    2. Use a unified entry file, determine the domain name in the entry file, that is, index.php, and jump to the corresponding directory according to the different domain names.

    I don’t want to say too much about this, it’s very simple. I’ll just post the sample code for you:


    // Define the application directory based on the domain name
    $server = $_SERVER['SERVER_NAME' ];
    if($server == '****.com'){
    define('APP_PATH','./Mzhuisu/');
    }else{
    define(' APP_PATH','./Home/');
    }

    reply
    1
  • Cancelreply