系统:CentOS7
Apache Httpd版本:2.4.41
Apache Httpd安装方式:源码安装
1. 安装rewrite
安装Apache时增加–enable-rewrite参数
./configure --enable-rewrite
2. 编辑httpd.conf
vi /usr/local/apache2/conf/httpd.conf
去掉 #LoadModule rewrite_module modules/mod_rewrite.so
前面的注释
加入以下代码:
<IfModule rewrite_module>
RewriteEngine on
RewriteRule .*$ http://www.qq.com
</IfModule>
3. 重启Apache
/usr/local/apache2/bin/apachectl restart
4. 测试
curl -v 192.168.100.8
大功告成!