Apache configuration to achieve the secondary domain name to access the directory on linux

In the following we will test directory implemented using www.test.mytest.com visit the following root

 

Tencent cloud Here is an example:

First you have to have a cloud host a public network ip

There is an example of a primary domain www.mytest.com

www.mytest.com has been resolved to your public ip

Add Record

Here the recording paper should fill in your public ip

 

 Here add a record about 10 minutes to use the record

Find your apache configuration file

find / -name httpd.conf

Open the file or

vi $(find / -name httpd.conf)

 

 

Add to

<VirtualHost *:80>
DocumentRoot /var/www/test
ServerName test.mytest.com
<Directory "/var/www/test">
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

 

or

 # Enable url rewrite mode

RewriteEngine on
 
 
In the website root directory htaccess fill
 

 

<VirtualHost *:80>
DocumentRoot /var/www/test
ServerName test.mytest.com
<Directory "/var/www/test">
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

 

Fill it in

apachectl restart 重启apachectl

To / var under / www directory create a directory test

Add the test in index.html

Address bar

www.test.mytest, com / index.html to access

 

Guess you like

Origin www.cnblogs.com/webcyh/p/11262168.html