如何在不编辑 .htaccess 文件的情况下重定向非 php 文件的 URL?

发布于 2024-12-06 04:03:58 字数 186 浏览 15 评论 0原文

所以基本上我需要一种方法来获取我的服务器上的 exe 文件并创建一个 php 函数来切换它的可用性。我不想只是重命名、移动或删除文件,而是重定向到解释该文件暂时不可用的页面。

我知道如何在 .htaccess 中设置永久重定向,但这并不能解决我的问题,因为我想通过 php 脚本使其自动化......

有什么建议吗?提前致谢。

So basically I need a way to take an exe file on my server and make a php function to toggle it's availability. I do not want to just rename, move, or delete the file, but redirect to a page explaining the file is temporarily unavailable.

I know how to set a permanent redirect in .htaccess but this doesn't solve my problem since I'd like to make this automated via a php script....

Any suggestions? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

渡你暖光 2024-12-13 04:03:58

您将无法单独使用 PHP 来执行此操作,除非您的 Web 服务器设置为将 .exe 文件的请求处理为 .php,或者您在.htaccess。如果该文件存在,并且 .htaccess/server 设置允许直接访问文件,则 PHP 无法阻止对其的访问。

You won't be able to do this with PHP alone unless your web server is set up to process requests for .exe files as .php, or you add a rule in .htaccess. If the file exists, and .htaccess/server settings allow direct access to files, there's nothing PHP can do to stop access to it.

人疚 2024-12-13 04:03:58

老实说,最简单的方法可能是编写一个 PHP 脚本来编辑 .htaccess 文件并在 apache 中重新加载它。每当您需要启用/禁用访问时,您都可以运行该脚本。

Honestly the simplest way would probably be to write a PHP script that edits your .htaccess file and reloads it in apache. You could just run that script whenever you needed to enable/disable access.

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