apache开启.htaccess

打开httpd.conf(在那里? APACHE目录的CONF目录里面),用文本编纂器打开后,查找 
(1) 
Options FollowSymLinks 
AllowOverride None 

改为 
Options FollowSymLinks 
AllowOverride All 

(2)去掉下面的注释 
LoadModule rewrite_module modules/mod_rewrite.so 

DocumentRoot "D:WebWEBAPI"
<Directory "D:WebWEBAPI">
#
# 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.4/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:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

(不)使用.htaccess文件的场合 
  一般情况下,不应该使用.htaccess文件,除非你对主配置文件没有访问权限。有一种很常见的误解,认为用户认证只能通过.htaccess文件实现,其实并不是这样,把用户认证写在主配置文件中是完全可行的,而且是一种很好的方法。 
  .htaccess文件应该被用在内容提供者需要针对特定目录改变服务器的配置而又没有root权限的情况下。如果服务器管理员不愿意频繁修改配置,则可以允许用户通过.htaccess文件自己修改配置,尤其是ISP在同一个机器上运行了多个用户站点,而又希望用户可以自己改变配置的情况下。 
  虽然如此,一般都应该尽可能地避免使用.htaccess文件。任何希望放在.htaccess文件中的配置,都可以放在主配置文件的段中,而且更高效。 
避免使用.htaccess文件有两个主要原因。 
  首先是性能。如果AllowOverride启用了.htaccess文件,则Apache需要在每个目录中查找.htaccess文件,因此,无论是否真正用到,启用.htaccess都会导致性能的下降。另外,对每一个请求,都需要读取一次.htaccess文件。 
  还有,Apache必须在所有上级的目录中查找.htaccess文件,以使所有有效的指令都起作用,所以,如果请求/ctusky/ctu/sky中的页面,Apache必须查找以下文件: 

/.htaccess 
/ctusky/.htaccess 
/ctusky/ctu/.htaccess 
/ctusky/ctu/sky/.htaccess  一共就要访问4个额外的文件,就算这些文件都不存在,这也是本文开始说会影响服务器的一点性能的原因。 
  其次是安全。这样会允许用户自己修改服务器的配置,这可能会导致某些意想不到的修改,所以请认真考虑是否应当给予用户这样的特权。

原文地址:https://www.cnblogs.com/ilookbo/p/5782903.html