如何强制 apache 请求使用 CGI 而不使用 .htaccess

发布于 2024-07-14 10:23:58 字数 359 浏览 1 评论 0原文

我的学校内部网络服务器仍在运行 PHP v4。.(不确定)。 我继续在运行 5.2.5 的本地计算机上编写了所有实验和作业。 现在,我的代码都无法在学校机器上运行,因为根本不存在该功能。

我可以使用大量编译器,并下载了 PHP v5.2.9 源代码,并将对其进行编译以用作 CGI。

我的问题? 学校已禁用我们帐户的 .htaccess 文件,因此我无法神奇地重定向所有请求以完成我的全新 v5.2.9 安装。

有没有人有任何想法、建议、黑客或解决方法来让所有请求转到我的 cgi 版本而不是 mod_php 版本? 有什么办法可以通过 301 重定向或其他方式来做到这一点吗?

万分感谢。

My school internal webserver is still running PHP v4.. (Not sure exactly). I went ahead and wrote all the labs and assignments on my local machine, which is running 5.2.5. Now, none of my code works on the school machine because the functionality simply is not there.

I have access to a slew of compilers, and have downloaded the PHP v5.2.9 source code, and am going to compile it for use as a CGI.

My problem? The school has disabled .htaccess files for our accounts, and thus I can't magically redirect all requests to go through my brand new v5.2.9 install.

Does anyone have any ideas, suggestions, hacks, or workarounds to get all requests to go to my cgi version rather than the mod_php version? Is there any way to do this with 301 redirects or something?

Thanks a ton.

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

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

发布评论

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

评论(2

眼眸里的那抹悲凉 2024-07-21 10:23:58

查看您的 Web 根目录中是否有 /cgi-bin 目录。 即使它不存在,也请尝试创建它并将脚本放在那里。 许多 Web 服务器默认情况下会假定该目录中的文件是脚本。

此外,您还需要尝试:

  1. 使用 .cgi 扩展名重命名脚本
  2. 在顶部放置“shebang 行”以指示要使用的解释器。 例如:

#!/path/to/php5

请注意,它必须是第一行,不能有空格。

See if you have a /cgi-bin directory in your web root. Even if it's not there, try creating it and putting your scripts there. Many web servers will by default assume that files in that directory are scripts.

Additionally, you will want to try:

  1. Renaming your scripts with a .cgi extension
  2. Putting a "shebang line" at the top to indicate what interpreter to use. For example:

#!/path/to/php5

Note that it has to be the first line with no spaces.

那请放手 2024-07-21 10:23:58

您可以使用 PHP4 进行重定向。 使用 标头 函数。 或者,您可以使用 passthru 从 PHP4 脚本执行 CGI。

You can do the redirect with… PHP4. Use the header function. Or you can execute your CGI from a PHP4 script using passthru.

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