apache2配置rewrite_module

環境:debian6.4, apache2.2.16php

配置步驟:css

一、配置apache的rewrite_module(說明,個人apache配置文件和路徑都是默認路徑,apahce是經過apt-get install安裝的)html

    在/opt/etc/apache2/mods-enabled/路徑下新建一個文件"rewrite.load",文件內容爲"LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so"web

二、配置apache虛擬機的rewriteapache

   修改文件 /etc/apache2/sites-available/default裏面的虛擬機配置,在<VirtualHost *:80>節點裏面增長以下內容jsp

    <Directory /var/www/cavy/www>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>ide

三、配置.htaccess文件,在web的跟目錄下建立.htaccess文件,文件內容爲:htm

    <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>get

    注:filter_File爲須要執行的文件,如filter.jsp,filter.php等虛擬機

相關文章
相關標籤/搜索