apache配置二级域名

我们需要登录所购域名运营商的域名管理后台,点击‘域名解析':


手动添加或一键快速添加下面两条默认解析,形如www.csdn.net和csdn.net的域名就可以访问主机地址了

添加一条需要配置的二级域名解析:

然后在Apache配置文件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>

重启Apache,这时形如blog.csdn.net的二级域名就可以访问了

猜你喜欢

转载自blog.csdn.net/qq_43737121/article/details/109135676