【发布时间】:2011-07-15 22:04:57
【问题描述】:
我正在开发一个 PHP 网站,它在 Apache 2.2 和 Windows 7 的 localhost 上运行。
在我的 httpd.conf 中,我启用了 mod_rewrite 模块:
LoadModule rewrite_module modules/mod_rewrite.so
我的文档根目录位于 D:\MyWeb,我正在处理的网站位于 D:\MyWeb\simple_cms
出于测试目的,我将 .htaccess 文件放在 D:\MyWeb\simple_cms 中,这是它的内容:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]
现在,调用http://127.0.0.1/simple_cms/index.htm 应该“重定向”到http://127.0.0.1/simple_cms/index.php 但它显示“404 Not Found Error”(当然 index.php 存在那里)
在access.log中有:
127.0.0.1 - - [15/Jul/2011:14:16:15 +0200] "GET /simple_cms/index.htm HTTP/1.1" 404 218
在error.log里面:
[Fri Jul 15 14:19:30 2011] [error] [client 127.0.0.1] File does not exist: D:/MyWeb/simple_cms/index.htm
为什么这不起作用?这个正则表达式无效吗?
【问题讨论】:
-
1) 确保启用 .htaccess 文件(将
AllowOverride All放在适当的位置); 2) 请开启rewrite调试(RewriteLogLevel 9)并查看rewrite log。 -
AllowOverride All- 基本上,这就是答案。请把它作为一个新的答案,这样我就可以接受它。谢谢
标签: windows apache mod-rewrite