ThinkPHP supports the deployment of group second-level domain names. this function enables multiple groups in the project to be displayed as second-level domain names. for example, after configuring second-level domain name deployment, you can
ThinkPHP supports the deployment of group second-level domain names. this function enables multiple groups in the project to be displayed as second-level domain names. for example, after configuring second-level domain name deployment, you can:
Http://domain.com/index.php/admin/sharehttp://domain.com/admin/
Changed to http://admin.domain.com/access mode.
Configure the domain name first. take apache as an example. the configuration is as follows:
# Primary domain name
- DocumentRoot D: \ htdocs \ www
- ServerName domain.com
# Subdomain name
- DocumentRoot D: \ htdocs \ www
- ServerName admin.domain.com
- ServerAlias * .domain.com
Then configure the host. take windows as an example to edit the C: \ WINDOWS \ system32 \ drivers \ etc \ hosts file and add the following two lines:
- 127.0.0.1 domain.com
- 127.0.0.1 admin.domain.com
Next, modify the configuration file config. php of the program as follows:
- 'App _ GROUP_LIST '=> 'Home, Test, admin ',
- 'Default _ group' => 'home ',
- 'App _ SUB_DOMAIN_DEPLOY '=> 1, // enable subdomain configuration
- /* Subdomain configuration
- * Format: 'subdomain name' => array ('group name/[module name] ', 'var1 = a & var2 = B ');
- */
- 'App _ SUB_DOMAIN_RULES '=> array (
- 'Admin' => array ('admin/'), // The admin domain name directs to the Admin group
- 'Test' => array ('test/'), // The test domain name directs to the Test group.
- ),
Try it on your own!