.htaccess 中定义的操作不执行
我在 Windows 7 笔记本电脑上安装了 WAMP。
接下来,我定义了一个别名(WAMPSERVER -> Apache -> 别名目录 -> 添加别名)
Alias name: test
Alias directory: c:/test
接下来,我将一个 PHP 文件放入该目录中 (c:/test/foo.php)。我在浏览器中执行了 URL
http://localhost/test/foo.php
并成功检索了 PHP 文件。
现在,我在同一目录 (c:/test/.htaccess
) 中添加了一个 .htaccess
文件,其中包含以下内容:
Action controller-test /foo.php
AddHandler controller-test .tst
最后,我尝试执行 URL http://localhost/test/testing.tst
在我的浏览器中,但我得到了一个“404 未找到”页面。 foo.php
页面不应该被检索到吗?我做错了什么?
(我按照这篇文章中的说明进行操作。
)还在 .htaccess
文件中添加了 IndexIgnore */*
行,这导致目录列表被隐藏,因此我可以确认 .htaccess
代码> 文件有效。
I installed WAMP on my Windows 7 laptop.
Next, I defined an alias (WAMPSERVER -> Apache -> Alias directories -> Add an alias)
Alias name: test
Alias directory: c:/test
Next, I've placed a PHP file into that directory (c:/test/foo.php
). I executed the URL http://localhost/test/foo.php
in my browser and the PHP file was successfully retrieved.
Now, I added an .htaccess
file into that same directory (c:/test/.htaccess
) with the following content:
Action controller-test /foo.php
AddHandler controller-test .tst
Finally, I tried to execute the URL http://localhost/test/testing.tst
in my browser but I got a "404 Not found" page. Shouldn't the foo.php
page have been retrieved? What am I doing wrong?
(I followed the instructions from this article.)
I have also added the line IndexIgnore */*
to the .htaccess
file which caused the directory listing to be hidden, so I can confirm that the .htaccess
file works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您遵循的文章中:“由 Action 命名的可执行文件是相对于文档根目录的。”
因此您必须将
foo.php
向上移动一层或编写From the article you followed: "The executable named by Action is relative to the document root."
So you have to move
foo.php
one level up or write