apache的rewrite模块能够很好的支持url的重构,使之对搜索引擎友好,现在许多的程序都已经支持rewrite功能,比如大名鼎鼎的博客程序wordpress和国内的bo-blog,论坛程序如phpwind和discuz!,还有一些cms程序比如dedecms,supesite, VeryCMS等等。要使用rewrite功能,还要启用apache的rewrite模块,本来php自身也支持rewrite,但是功能有限,根强大的apache比起来还是有很大差别的。
下面介绍一下怎样打开apache的mod_rewrite功能。
首先来重新编译安装apache-2.0.59
#tar -zxvf httpd-2.0.59.tar.gz
#cd httpd-2.0.59
#./configure --prefix=/opt/apache2 --enable-modules=so --enable-module=rewrite --enable-shared=rewrite --enable-shared=max
#make
#make install
apache安装完毕,下面来加载编译mod_rewrite.so这个模块。
#cd /soft/httpd-2.0.59/modules/mappers
#/opt/apache2/bin/apxs -c mod_rewrite.c -lgdbm
#gcc -shared -o mod_rewrite.so mod_rewrite.o -lgdbm
#/opt/apache2/bin/apxs -i -A -n rewrite mod_rewrite.so