Apache configuration second-level domain name

We need to log in to the domain name management background of the operator of the purchased domain name and click on "Domain Resolution":


Manually add or one-click to quickly add the following two default resolutions, domain names like www.csdn.net and csdn.net can access the host address

Add a second-level domain name resolution that needs to be configured:

Then add the following domain name configuration at the end of the Apache configuration file httpd.conf:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<VirtualHost *:80>

  ServerAdmin [email protected]

  DocumentRoot /usr/local/apache/htdocs

  ServerName www.csdn.net

  ServerAlias www.csdn.net csdn.net

  DirectoryIndex index.php index.html index.htm 

</VirtualHost>

<VirtualHost *:80>

  ServerAdmin [email protected]

  DocumentRoot /usr/local/apache/htdocs/blog

  ServerName blog.csdn.net

  ServerAlias blog.csdn.net

  DirectoryIndex index.php index.html index.htm 

</VirtualHost>

Restart Apache, then the second-level domain name like blog.csdn.net can be accessed

Guess you like

Origin blog.csdn.net/qq_43737121/article/details/109135676