首先,你必须要确认Apache安装目录下面conf/httpd.conf文件中已经开启:


#代码1#

LoadModule rewrite_module modules/mod_rewrite.so

然后你要在httpd.conf文件中指定你所想要实现rewrite功能的目录和配置,如下所示:




#代码2#

<Directory "D:\www\bc"> #指定你需要执行下面rewrite规则的目录
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All #此处原来的值是默认为 —— None ,
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
</Directory>


介绍一下在上面#代码2#前面的那一段配置代码:


DocumentRoot "D:\www" #指定Apache Service 的根目录
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory /> # 指定Apache Service 根目录的各种权限:AllowOverride|Order deny,allow              # Deny from all
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>