Apache 中的 .htaccess 不工作

.htcaccess in Apache not working

我启用了 mod_rewrite 并想将我的一个本地虚拟主机网站重定向到 google.com 进行练习。

我在我的虚拟目录 (/var/www/example.com/.htcaccess) 中创建了一个 .htcaccess 文件,并通过将以下代码添加到我的虚拟主机 (example.com) 配置中授予 .htcaccess 权限在 /sites-available/.

 <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
 </Directory>

我现在正尝试通过向 .htcaccess 文件添加代码来使用 mod_rewrite,但到目前为止没有成功。有什么方法可以检查 .htcaccess 是否正常工作?如果是,我如何使用 mod_rewrite 重定向?

有错字。通常文件名是 .htaccess,而不是 .htcaccess.

另一种选择是将文件名设置为您 "personal style",例如:

 AccessFileName .htcaccess 

http://httpd.apache.org/docs/2.2/howto/htaccess.html