【问题标题】:url rewriting: I don't see index.html but a 404 errorurl 重写:我没有看到 index.html 而是 404 错误
【发布时间】: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


【解决方案1】:

您可能指的是^index\.bla$,如果您直接访问 my_vm_ip/index.html,您会看到该页面吗?如果不是,您可能缺乏该文件的权限

【讨论】:

    猜你喜欢
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 2014-12-17
    • 2010-12-17
    • 1970-01-01
    • 1970-01-01
    • 2013-11-26
    • 1970-01-01
    相关资源
    最近更新 更多