apacle域名301跳转
1、编辑虚拟主机配置文件vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
2、添加跳转模块
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST] ^www.aaa.com$
RewriteRule ^/(.*)$ http://www.test.com/$1
</IfModule>
3、重新加载
/usr/local/apache2/bin/apachectl graceful
4、检查配置是否有错后重启服务
/usr/local/apache2/bin/apachectl -t
/usr/local/apache2/bin/apachectl restart
5、如果需要配置两个域名重定向需要加or
<VirtualHost *:80>
DocumentRoot "/data/www"
ServerName www.test.com
ServerAlias www.aaa.com
ServerAlias www.bbb.com
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST] ^www.aaa.com$
RewriteCond %{HTTP_HOST] ^www.bbb.com$
RewriteRule ^/(.*)$ http://www.test.com/$1
页:
[1]