apache2配置rewrite_module
环境:debian6.4, apache2.2.16
配置步骤:
1、配置apache的rewrite_module(说明,我的apache配置文件和路径都是默认路径,apahce是通过apt-get install安装的)
在/opt/etc/apache2/mods-enabled/路径下新建一个文件"rewrite.load",文件内容为"LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so"
2、配置apache虚拟机的rewrite
修改文件 /etc/apache2/sites-available/default里面的虚拟机配置,在<VirtualHost *:80>节点里面增加如下内容
<Directory /var/www/cavy/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
3、配置.htaccess文件,在web的跟目录下创建.htaccess文件,文件内容为:
<IfModule mod_rewrite.c>
RewriteEngine on
#http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritebase
# uncomment to set relatived www root dir
#RewriteBase /var/www
RewriteRule !\.(js|ico|gif|jpg|png|css|php)$ filter_File
</IfModule>
注:filter_File为需要执行的文件,如filter.jsp,filter.php等