WordPress knowledge sharing

AliCloud virtual host method for establishing multiple websites

Today, a friend asked Weieis blog if he wanted to AliCloud virtual host contains multiple websites What to do? Old Wei has not touched the virtual host for a long time. He has studied it and found a solution. Now let's talk about how to build multiple websites on AliCloud virtual host.

AliCloud virtual host can only host one website. In order to build multiple websites, you need to use the pseudo static file. htaccess file. The content about domain name resolution and virtual machine binding domain name is omitted.

Supplement on March 6, 2020:

This operation is not recommended on the virtual host. Now buy one ECS Less than 100 yuan a year, it is not cost-effective to buy a virtual host of 400 yuan a year.

Relevant knowledge:

How to create a. htaccess file

Alibaba Cloud virtual machine provides a website folder, that is, a website A can be placed in the root directory. If you want to place an additional website B, let's assume that the domain name is www.vpsss.net, and you also need to create a folder with any name. I call it bweb, that is, the root directory of website B.

You can set up multiple websites on AliCloud virtual machines through the following operations.

1. Create a. htaccess file in the root directory of Alibaba Cloud virtual machine, with the following contents:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^ www.vpsss.net $ [NC]
RewriteCond %{REQUEST_URI} !^/ bweb
RewriteRule ^(.*)$ / bweb /$1 [L]
#To bind multiple websites, repeat the above three lines of code and change the corresponding domain name and directory name
</IfModule>

2. Create a. htaccess file in the bweb folder. The contents are as follows:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^ www.vpsss.net $ [NC]
RewriteRule (.*) https:// www.vpsss.net /$1 [L,R=301]

Note that the above red text needs to be replaced.

3. If you want to build a third website, copy and paste the three lines of red text in 1 again below, and modify the corresponding domain name and folder name.

4. Any virtual host that can use. htaccess in the Apache environment can use this method to achieve coexistence of multiple websites.

5. Get vouchers and participate in Alibaba Cloud promotional activities

Compared with VPS, it is a bit troublesome for virtual hosts to realize the coexistence of multiple websites. Some virtual hosts support the establishment of multiple independent websites, which can be achieved by binding domain names in the management background. Alibaba Cloud virtual hosts have one domain name corresponding to one website, so only this can be done at a glance.

Like( zero )
Article name: AliCloud Virtual Host Method for Building Multiple Websites
Article link: https://www.vpsss.net/5057.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.