Detailed explanation of how to configure secondary domain name on Apache server under Linux environment

Detailed explanation of how to configure secondary domain name on Apache server under Linux environment

This article describes how to configure a secondary domain name on an Apache server in a Linux environment. Share with you for your reference, the details are as follows:

(Take the domain name www.csdn.net as an example, now you need to configure a secondary domain name blog.csdn.net to point to the host address)

First, make sure to enable the mod_rewrite module in the Apache configuration file httpd.conf:

Here is a brief introduction to this module:


Next, we need to log in to the domain name management backend of the purchased domain name operator and click 'Domain Name Resolution':


Manually add or quickly add the following two default resolutions with one click. Domain names such as www.csdn.net and csdn.net can access the host address.

Add a secondary 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:

<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, and then the secondary domain name such as blog.csdn.net can be accessed

I hope this article will help you configure your Linux server.

You may also be interested in:
  • Apache secondary domain name resolution (windows and linux)
  • Linux Apache wildcard domain name resolution and DNS related
  • Detailed explanation of how to configure multiple domain names in Nginx on Alibaba Cloud Linux system
  • Implementation of virtual domain name under Linux (1)
  • Implementation of virtual domain name under Linux (2)
  • Implementation of virtual domain name under Linux (3)
  • Springboot+nginx+https+linux to achieve load balancing and domain name access simple test
  • How to configure virtual host under linux apache
  • Sharing of Apache server configuration and management methods under CentOS (Linux)
  • Detailed notes on installation and configuration of Apache, MySQL, and PHP under Linux
  • PHP+MYSQL+APACHE configuration process under Linux (excerpt)

<<:  Detailed explanation of the reasons and optimizations for the large offset affecting performance during MySQL query

>>:  How to use axios request in Vue project

Recommend

Common styles of CSS animation effects animation

animation Define an animation: /*Set a keyframe t...

View the command to modify the MySQL table structure

Brief description The editor often encounters som...

How to remount the data disk after initializing the system disk in Linux

Remount the data disk after initializing the syst...

WeChat applet implements login interface

The login interface of WeChat applet is implement...

Install Windows Server 2019 on VMware Workstation (Graphic Tutorial)

If prompted to enter a key, select [I don’t have ...

How to enable MySQL remote connection in Linux server

Preface Learn MySQL to reorganize previous non-MK...

Summary of MySQL logical backup and recovery testing

Table of contents 1. What kind of backup is a dat...

Nginx domain name SSL certificate configuration (website http upgraded to https)

Preface HTTP and HTTPS In our daily life, common ...

How to start a Java program in docker

Create a simple Spring boot web project Use the i...

Detailed explanation of Js class construction and inheritance cases

The definition and inheritance of classes in JS a...

Thinking about grid design of web pages

<br />Original address: http://andymao.com/a...

Writing Snake Game with Native JS

This article shares the specific code of writing ...

Detailed explanation of the use of JavaScript functions

Table of contents 1. Declare a function 2. Callin...

JavaScript setinterval delay one second solution

When using setinterval, it is found that it will ...