【发布时间】:2011-11-01 03:45:21
【问题描述】:
我的 vm 上安装了最新版本的 apache2。
我通过以下方式激活了 mod_rewrite:
a2enmod rewrite
/etc/init.d/apache2 restart
现在我只是测试了一个小规则,但它不起作用。 我的网站根目录上有一个 .htaccess 和一个 index.html。 .htaccess 包含:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^index.bla$ index.html [L]
但是当我转到 my_vm_ip/index.bla 时,我没有看到 index.html,而是看到 404 错误!
【问题讨论】:
-
因为你可以完全控制你的服务器,我建议启用重写调试 (
RewriteLoglevel 9) 并检查重写日志——它应该告诉你帽子正在发生。另一个可能的原因——Apache配置不允许.htaccess文件——你需要将AllowOverride All应用到网站文件夹——请查看Apache手册以获取上述指令。 -
我刚刚在apache2.conf的末尾添加了:
-
AllowOverride All 但这并没有改变 :( -
那么......重写日志说了什么?
-
绝对没有......在error.log中我只有文件未找到错误。
标签: apache mod-rewrite apache2 url-rewriting