简洁的想法

仁爱、喜乐、和平、忍耐、恩慈、良善、信实、温柔、节制

Enable Apache Mod_rewrite on Windows

| Comments

我用的是xampp的网络编程环境,默认配置下,Apache mod_rewrite 是禁用的。

要开启其实并不难,找到httd.conf文件,把下面代码前面的#去掉就可以了。
重启Apache,用phpinfo()看一下,OK,mod_rewrite装载成功。

#LoadModule rewrite_module modules/mod_rewrite.so

蛮有信心地打开站点,结果没起作用。:(

回到httd.conf文件,鼻子贴着显示器找,发现可疑区块
#
# Note that from this point forward you must specifically allow
# particular features to be enabled – so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory “D:/Program Files/WebDev/html”>
#
# 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 Includes ExecCGI

#
# 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 none

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all



其中发现一句

AllowOverride none

这就是问题所在了。把 none 改成 all ,搞定!

Comments