【发布时间】:2014-12-08 02:23:21
【问题描述】:
我在我的 Mac 上运行 localhost XAMPP 并尝试使用 mod_rewrite 设置 Apache 服务器,这是我在 .htaccess 中的代码(在 htdocs 中)
<IfModule mod_rewrite.c>
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^test/?$ api/rest/v1.0/api_controller.php?request=$1 [NOCASE,LAST] # Handle requests for “test"
RewriteLog "logs/rewritelog"
RewriteLogLevel 7
</IfModule>
这也是.htaccess 文件中唯一的代码。
当我在浏览器中尝试链接 http://localhost/test/1 时,我只是被定向到 404 错误。
我在 htdocs/logs/rewritelog 下检查过,但没有任何文件,甚至没有名为 logs 的文件夹。
更新
我正在运行 Apache 版本 2.4.10
【问题讨论】:
-
您没有匹配
/test/1的重写规则。也许试试^test/(.*)$ -
谢谢,但还是没有成功
-
对为什么没有日志有什么想法吗?
-
没有重写日志,因为您的 URL
/test/1不匹配任何重写规则。 -
我尝试通过将“IfModule”重命名为“le”来破坏文件,但发生了同样的错误。我认为我的服务器忽略了
.htaccess文件
标签: php apache .htaccess mod-rewrite