配置Apache支持.htacess(分布式配置文件)

.htaccess文件(或者"分布式配置文件")提供了针对目录改变配置的方法, 即,在一个特定的文档目录中放置一个包含一个或多个指令的文件, 以作用于此目录及其所有子目录。作为用户,所能使用的命令受到限制。管理员可以通过Apache的AllowOverride指令来设置。

将“AllowOverride”的值设置为“All”表示支持,设置为“None”表示不支持。

例如,设置全局虚拟目录都支持.htaccess文件:
<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

如果,局部设置某个虚拟目录支持.htaccess文件:
<VirtualHost *:80>
 ServerNamewww.feihusky.loc
 DocumentRoot "D:\webs\feihusky\www"
<Directory "D:\webs\feihusky\www">
 DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml
 AllowOverride All
 Order Deny,Allow
 Allow from all
</Directory>
</VirtualHost>


当在“.htaccess”文件中使用RewriteEngine命令时,需要rewrite mod的支持:
$>cd /etc/apache2/mods-enabled    切换到apache下的mods-enabled目录
$>sudo ln -s ../mods-available/rewrite.load rewrite.load   启用rewrite mod
$>sudo /etc/init.d/apache2 restart    重启apache服务器。
或者在apache的配置文件httpd.conf中将#LoadModule rewrite_module modules/mod_rewrite.so前的#去掉,再重启服务器。

 

posted @ 2011-07-01 21:46  飞虎cnblog  阅读(451)  评论(0)    收藏  举报
友情链接:技术迷 | JSM官方博客 | 阿旭博客 | 有声小说在线听