首先,你必需要確認Apache安裝目錄下面conf/httpd.conf文件中已經開啓:php
#代碼1# LoadModule rewrite_module modules/mod_rewrite.so
而後你要在httpd.conf文件中指定你所想要實現rewrite功能的目錄和配置,以下所示:html
#代碼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#前面的那一段配置代碼:apache
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>