Apache configure domain name 301 jump
Configure domain name 301 jump
When there are two domain names, we need to set a primary domain name (jump the secondary domain name to the primary domain name). The operation command is as follows:
Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf
Add the following line under # CustomLog "logs/dummy-host.example.com-access_log" common:
RewriteEngine on
RewriteCond% {HTTP_HOST} ^ www.aaa.com$
RewriteRule ^ / (. *) $http://www.test.com/%1 [Rust 301m L]
Save exit
# Redirect 301 permanent redirect domain name jump must use 301, which is good for the browser
Jump 302 indicates temporary redirection
Apachectl-M # observe whether the rewrite_module module is loaded
Apachectl-t
Apachectl restart
Curl-x192.168.1.113: 80 www.aaa.com/dsgsdgsdfg-I # test whether the domain name jumps normally
If there are more than two domain names, the operations are as follows:
Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf
Add:
I
RewriteCond% {HTTP_HOST} ^ www.aaa.com$ [OR]
RewriteCond% {HTTP_HOST} ^ www.bbb.com$
Save exit
Apachectl-t
Apachectl restart
Curl-x 192.168.1.113: 80 www.bbb.com/asllsdfsf-I