【问题标题】:Request remote file with file_get_contents()使用 file_get_contents() 请求远程文件
【发布时间】:2011-02-13 13:32:15
【问题描述】:

我需要查询另一个域上的页面并显示它返回的结果。但是 php

文件报告错误。

网址是:http://otherdomain/abc.jsp?p=q&x=y

编辑:我使用 file_get_contents...

【问题讨论】:

  • 如果您希望我们修复此错误,您必须告诉我们错误是什么。

标签: php http file-get-contents


【解决方案1】:

可能有几个原因:

1) 如果您打开的 URI 包含特殊字符(例如空格),则需要使用 urlencode() 对 URI 进行编码。

2) 在您的 php.ini 中,*allow_url_fopen* 为假。设置为 true 以允许打开 url。

如果您提供 php 生成的错误,我可以提供帮助。

如果您试图让两个或多个起点访问同一个点,您可以考虑使用带有 RewriteEngine 的 .htaccess 文件,因为它会重写 url。

如果您想: index.jspindex.phpindex.aspx....都显示与 index.jsp 显示。

您可以使用: .htaccess 文件,支持 RewriteEngine。

这里是一些.htaccess tricks的链接

通知 您必须将 Apache 作为 HTTP 服务器并启用 mod_rewrite 模块。

【讨论】:

    猜你喜欢
    • 2012-05-18
    • 2013-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-08
    • 1970-01-01
    • 1970-01-01
    • 2010-10-16
    相关资源
    最近更新 更多