[Apache] uses serveralias in Apache to set a virtual host to receive multiple domain names and set wildcard domain name resolution.

Source: Internet
Author: User

Serveralias: Server alias. It can be used in Apache to set the domain name received by the VM or to receive the domain name for wildcard resolution. The specific settings are as follows:

1. Set the VM to receive multiple domain names

A virtual host often receives multiple domain name resolutions, such as a virtual host to introduce both doctor-c.net, doctor-c.com two domain names, or two second-level domain names, such as: www.doctor-c.net, www1.doctor-c.net, for this situation, serveralias can be easily used, and the redirection implemented in this method is 301 permanent redirection, open the Apache setting file: httpd. conf.CodeMedium:

<Virtualhost *>

Servername "doctor-c.net" # default domain name;

Serveralias doctor-c.com doctor-c.net www1.doctor-c.net # different domain names are separated by spaces;

DocumentRoot "D: \ wwwroot \ doctor-c.net"

<Directory "D: \ wwwroot \ doctor-c.net">

Options indexes followsymlinks

AllowOverride all

</Directory>

</Virtualhost>

Save the httpd. conf file and restart Apche.

Ii. Receiving wildcard domain name resolution

A virtual host can receive wildcard domain name resolution and is also set through the severalias option. By setting this option, it can not only receive second-level wildcard domain name resolution, but also receive third-level and fourth-level wildcard domain name resolution, the specific settings are as follows:

<Virtualhost *>

Servername "doctor-c.net" # default domain name;

Serveralias * .doctor-c.net # uses * to represent a wildcard domain name. To receive a third-level wildcard domain name resolution, you can write it as follows: * .my.doctor-c.net;

DocumentRoot "D: \ wwwroot \ doctor-c.net"

<Directory "D: \ wwwroot \ doctor-c.net">

Options indexes followsymlinks

AllowOverride all

</Directory>

</Virtualhost>

Save the httpd. conf file and restart Apche.

[Doctor-c.net] synchronous publishing address: http://www.doctor-c.net/2012-02-23/99/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.