Home  >  Article  >  Backend Development  >  How to deploy second-level domain names in the tp5 framework

How to deploy second-level domain names in the tp5 framework

little bottle
little bottleforward
2019-04-22 10:20:346176browse

Some projects need to separate the mobile terminal and PC terminal. For example, when visiting xxx.com, the PC terminal page will be displayed. When visiting m.xxx.com, the mobile page is displayed. The main content of this article is to configure the second-level domain name in tp5. I will share it here with friends in need.

You can do this in thinkphp5:

First, modify url_domain_deploy to true in application\config.php, as follows:

'url_domain_deploy' =>  true

Secondly, register in application\route.php Domain name deployment rules.

Where m is the subdomain name, and mobile is the module name. This section indicates that any access with m as the subdomain name will be resolved to the mobile module.

<?phpuse think\Route;
Route::domain(&#39;m&#39;,&#39;mobile&#39;);

If it is configured locally, add

127.0.0.1  xxx.com127.0.0.1  m.xxx.com

in hosts. In addition:
Two virtual hosts must be configured in apache or nginx, one with a domain name of xxx. com, and the other domain name is m.xxx.com. The root directories both point to the public folder, but the port numbers of the two cannot be the same.

Related tutorials: PHP video tutorial

The above is the detailed content of How to deploy second-level domain names in the tp5 framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete