search
Homephp教程php手册Website deployment of first-level domain names, second-level domain names, and subdomain names

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 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 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 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 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 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 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></span></span></span></span></span></span>

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

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)