In the actual production environment, the Apache Server Web site often needs to maintain or discard the old domain name needs to use domain redirection, then can take advantage of the Apache service rewrite rules to quickly modify the virtual host to achieve 301 redirect, If you do not know the status code of the HTTP can see: http://jim123.blog.51cto.com/4763600/1836154
<virtualhost *:80> documentroot "/data/www/www.test1.com" ServerName www.test1.com# actual domain <directory/data /www/www.test1.com> allowoverride all rewriteengine on Order Allow,deny </directory></virtualhost><virtualhost *:80> ServerName www.test2.com# need to jump the domain name Redirectmatch per Manent ^/(. *) http://www.test1.com/$1# Jump www.test1.com</virtualhost>
After restarting Apache, using Curl-i www.test2.com authentication, the HTTP status value returned is 301 is the successful
This article is from the "Technical essay" blog, please be sure to keep this source http://jim123.blog.51cto.com/4763600/1851239
Configuration of Redirection 301 in Apache Environment