Deploy ThinkPHP second-level domain names

Source: Internet
Author: User
Tags subdomain subdomain name
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

  1. DocumentRoot D: \ htdocs \ www
  2. ServerName domain.com

# Subdomain name

  1. DocumentRoot D: \ htdocs \ www
  2. ServerName admin.domain.com
  3. 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:

  1. 127.0.0.1 domain.com
  2. 127.0.0.1 admin.domain.com

Next, modify the configuration file config. php of the program as follows:

  1. 'App _ GROUP_LIST '=> 'Home, Test, admin ',
  2. 'Default _ group' => 'home ',
  3. 'App _ SUB_DOMAIN_DEPLOY '=> 1, // enable subdomain configuration
  4. /* Subdomain configuration
  5. * Format: 'subdomain name' => array ('group name/[module name] ', 'var1 = a & var2 = B ');
  6. */
  7. 'App _ SUB_DOMAIN_RULES '=> array (
  8. 'Admin' => array ('admin/'), // The admin domain name directs to the Admin group
  9. 'Test' => array ('test/'), // The test domain name directs to the Test group.
  10. ),

Try it on your own!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.