.htaccess 中定义的操作不执行

发布于 2024-12-28 03:10:18 字数 944 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只有影子陪我不离不弃 2025-01-04 03:10:18

从您遵循的文章中:“由 Action 命名的可执行文件是相对于文档根目录的。

因此您必须将 foo.php 向上移动一层或编写

Action     controller-test /test/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

Action     controller-test /test/foo.php
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文