【发布时间】:2011-12-11 13:09:59
【问题描述】:
我正在尝试捕获每个 URL 并将其重写为 index.php。我现在的 .htaccess 中有以下代码:
RewriteEngine on
RewriteRule .* index.php
它确实重写了每个 URL,但我总是得到一个 404,说找不到 index.php 文件。它正在寻找文件的路径是正确的。我在这里做错了什么?
更新 1
当我直接浏览到 index.php 时,它确实正确显示了该文件。很奇怪。
更新 2
我在 httpd.conf 中使用它打开了 mod_rewrite 的日志记录:
RewriteLog /var/log/apache2/rewrite.log
RewriteLevel 3
这是它记录的内容:
strip per-dir prefix: /Users/rits/Sites/test/ ->
applying pattern '.*' to uri ''
rewrite '' -> 'index.php'
add per-dir prefix: index.php -> /Users/rits/Sites/test/index.php
internal redirect with /Users/rits/Sites/test/index.php [INTERNAL REDIRECT]
【问题讨论】:
标签: apache .htaccess mod-rewrite