root权限下运行a2enmod(a2enmod是一个可以配置Apache的工具,a2enmod是属于apache2.2-common包下的一个工具),然后输入rewrite启动apache对于.htaccess的支持。
a2enmod rewrite
在debian下默认的httpd.conf文件是空的,如果需要对相应目录设置AllowOverride,可以直接进入:
/etc/apache2/sites-enabled/000-default
可以按照要求把需要支持的地方的AllowOverride None改为AllowOverride All,如下例中:
<VirtualHost *:80>
ServerAdmin *@localhostDocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warnCustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>