Home > php教程 > php手册 > body text

Website deployment of first-level domain names, second-level domain names, and subdomain names

WBOY
Release: 2016-09-23 03:30:11
Original
3345 people have browsed it

About domain name introduction:

Generally speaking, a complete domain name is composed of two or more parts, and each part is separated by an English period "." For example, "www.baidu.com", the right part of the last "." ".com" becomes the top-level domain name (TLD), and also becomes the first-level domain name, similar to .cn, .net, .org, .gov, . edu, .tv, etc. Here .com.cn is actually the second-level domain name under .cn). Any individual can register a .com domain name, of which baidu.com is the second-level domain name under the top-level domain name .com. baidu.com can also be in the form of image.baidu.com, music.baidu.com, and imagemusic here can Called a "subdomain name";

Apache configuration for second-level domain names and subdomains:

Enter Apache-conf-extra-httpd-vhost.conf and add the following configuration:

<span style="color: #0000ff;"><</span><span style="color: #800000;">VirtualHost </span><span style="color: #ff0000;">*:80</span><span style="color: #0000ff;">></span><span style="color: #000000;">
    DocumentRoot "E:/wamp/www/galaxyPHP/"
    ServerName  testimmi.com
    ServerAlias m.testimmi.com
    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Directory </span><span style="color: #ff0000;">"E:/wamp/www/galaxyPHP/"</span><span style="color: #0000ff;">></span><span style="color: #000000;">
    Allow from all      
    </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Directory</span><span style="color: #0000ff;">></span>
    <span style="color: #0000ff;"><</span><span style="color: #800000;">IfModule </span><span style="color: #ff0000;">dir_module</span><span style="color: #0000ff;">></span><span style="color: #000000;">
       DirectoryIndex  mobile.php index.html index.htm default.php default.htm default.html
    </span><span style="color: #0000ff;"></</span><span style="color: #800000;">IfModule</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"></</span><span style="color: #800000;">VirtualHost</span><span style="color: #0000ff;">></span>

<span style="color: #0000ff;"><</span><span style="color: #800000;">VirtualHost </span><span style="color: #ff0000;">*:80</span><span style="color: #0000ff;">></span><span style="color: #000000;">
    DocumentRoot "E:/wamp/www/galaxyPHP/"
    ServerName  testimmi.com
    ServerAlias www.testimmi.com
    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Directory </span><span style="color: #ff0000;">"E:/wamp/www/galaxyPHP/"</span><span style="color: #0000ff;">></span><span style="color: #000000;">
    Allow from all      
    </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Directory</span><span style="color: #0000ff;">></span>
    <span style="color: #0000ff;"><</span><span style="color: #800000;">IfModule </span><span style="color: #ff0000;">dir_module</span><span style="color: #0000ff;">></span><span style="color: #000000;">
       DirectoryIndex  index.php index.html index.htm default.php default.htm default.html
    </span><span style="color: #0000ff;"></</span><span style="color: #800000;">IfModule</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"></</span><span style="color: #800000;">VirtualHost</span><span style="color: #0000ff;">></span>
Copy after login

DocumentRoot represents the directory where the website project is located, ServerName represents the second-level domain name, and ServerAlias ​​is the alias (a complete second-level domain name (with www.) or a subdomain name is allowed),

In the ThinkPHP project, different module entries can be easily distinguished by configuring different entry files index.php and mobile.php. Combined with the .htaccess file, the routing URL can be simplified.

If the httpd-vhost.conf file configuration does not work, there are two points to note:

1. The http-vhosts.conf module is allowed to be loaded in the Apache configuration file httpd.conf:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

2. Enable rewrite-module function;

In the test environment, you can configure the system host file and add

192.168.1.122 testimmi.com
192.168.1.122 m.testimmi.com
192.168.1.122 www.testimmi.com

Let’s simulate the situation of applying for a second-level domain name

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template