Method of binding multiple domain names to create multiple websites on the virtual machine of the World Wide Web

 Watson Blog September 11, 2017 15:29:12 The server comment three hundred and eight one Reading mode

Some time ago, Xi'an SEO shared an article about the method of "(personal test) AliCloud free virtual host subdirectory binding secondary domain name". Today Mo Xiaoyu Blog See“ Method of binding multiple domain names to create multiple websites on the virtual machine of the World Wide Web ”, bind different independent domain names to different subdirectories, which means that a virtual host has multiple independent websites and independent domain names.

在万网虚机上绑定多个域名创建多个网站方法

Method of binding multiple domain names to create multiple websites on the virtual machine of the World Wide Web

Bind multiple domain names to create multiple websites on the virtual machine of the World Wide Web as follows:

First, modify htaccess in the root directory of the host (if not, create a new one)

In the htaccess file Topmost Add the following code:

  1. RewriteEngine On  
  2. RewriteBase /  
  3.   
  4. RewriteCond %{HTTP_HOST} ^(www\.)wosn\.net$ [NC]  
  5. RewriteCond %{REQUEST_URI} !^/ wosn/  
  6. RewriteCond %{REQUEST_FILENAME} !- f  
  7. RewriteCond %{REQUEST_FILENAME} !- d  
  8. RewriteRule ^(.*)$ wosn/ $1   
  9. RewriteRule ^(/)$ wosn/index.php [L]  
  10.   
  11. RewriteEngine On  
  12. RewriteBase /  
  13.   
  14. RewriteCond %{HTTP_HOST} ^(www\.)abcd\.com$ [NC]  
  15. RewriteCond %{REQUEST_URI} !^/ aaa/  
  16. RewriteCond %{REQUEST_FILENAME} !- f  
  17. RewriteCond %{REQUEST_FILENAME} !- d  
  18. RewriteRule ^(.*)$ aaa/ $1   
  19. RewriteRule ^(/)$ aaa/index.php [L]  

The meaning of the above code is to Www.wosn.net or wosn.net Bind to the wosn folder; take Www.abcd.com or abcd.com Bind to the aaa folder; You can modify it accordingly. If you need to build a third website, just add another paragraph.

Secondly, solve the wosn.net/wosn problem by visiting www.wosn.net

After adding the above code, you will find that the content of www.wosn.net can also be accessed through wosn.net/wosn, which is not what we want to see, so we need to modify the htaccess file in the wosn and aaa folders respectively, and add the following code (taking the wosn folder as an example):

  1. RewriteEngine On  
  2. #No access through domain names other than this website
  3. RewriteCond %{HTTP_HOST} !^ (www.)wosn.net$ [NC]  
  4. RewriteRule ^.*$ [L,r=404]  

If it is an aaa folder, you can modify its domain name accordingly.

Finally, bind the two domain names to the virtual host.

The domain name and virtual machine binding tutorial can be referred to“ (Pro test) AliCloud free virtual host subdirectory is bound to the secondary domain name ”Article.

So far: binding multiple domain names to create multiple websites on the virtual machine of the World Wide Web has been fully realized. If there is any problem during the operation, please leave a message below to discuss.

Attachment: Detailed configuration of. htaccess

 Watson Blog
  • This article is written by Published on September 11, 2017 15:29:12
  • This article is collected and sorted by the website of Mutual Benefit, and the email address for problem feedback is: wosnnet@foxmail.com , please keep the link of this article for reprinting: https://wosn.net/496.html

Comment