Nginx binding multiple domain names

Source: Internet
Author: User

Nginx binding multiple domain names involved in the technology for the URL rewrite, you can first understand the background of knowledge and then come to learn.

Here is the domain name: www.sample.com for example

1. Create the sample.conf file in the/usr/local/nginx/conf folder

2. Write the following in it and Save:

server{                Listen;                server_name sample.cn www.sample.cn;                Root/home/www/sample;index index.html index.htm;                CharSet Utf-8;                Location/{root/home/www/sample;                        Index index.html index.htm;                }                            Location ~* \. (jpg|gif|png) $ {  if (-F $request _filename) {Expires max;break;}} Location ~/\.ht {                        deny all;                }}

3. Then open the nginx.conf file and append the following to the last line:

    include linkcp.conf;

4. Create the/home/www/sample folder and create the file in it index.html content as follows

5. Enter the domain name www.sample.com in the browser as shown below:

Test page!

Configuration complete

Nginx binding multiple domain names

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.