要为 Apache 加载 mod_rewrite 模组,如果 Apache 并未安装,可以在编译时加上 –enable-rewrite 便可以,但如果 Apache 已经安装好,而又不想重新编译 Apache 的话,可以用以下方法:
1. 首先 cd 到 Apache 的源代码目录并到 mod_rewrite.c 档案,
1. 在apache的源码安装目录中寻找mod_rewrite.c文件
|
1 |
find ./ -name mod_rewrite.c |
2. 进入 mod_rewrite.c 的目录并用 apxs 编译 mod_rewrite.c
|
1 2 3 |
cd PATH/to/mod_rewrite.c /usr/local/apache/bin/apxs -c mod_rewrite.c /usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.la |
3. 编译好 mod_rewrite.c 后,便开启 httpd.conf 加入以下内容:
LoadModule rewrite_module modules/mod_rewrite.so
然后重新启动 Apache 便可以了。