如何强制 apache 请求使用 CGI 而不使用 .htaccess
我的学校内部网络服务器仍在运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看您的 Web 根目录中是否有 /cgi-bin 目录。 即使它不存在,也请尝试创建它并将脚本放在那里。 许多 Web 服务器默认情况下会假定该目录中的文件是脚本。
此外,您还需要尝试:
#!/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:
#!/path/to/php5
Note that it has to be the first line with no spaces.
您可以使用 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.