1

我有一个网站托管在我的本地服务器 (http://localhost/) 上,它使用 url_rewriting。

当我使用浏览器访问页面时,没问题,它正在加载。
但是当我使用 PHP cUrl 访问相同的 url 时,我得到了 404。

示例:
带有 mod_rewrite 的 URL:http://localhost/site/test
真实页面:http://localhost/site/test.php

从 Firefox加载http://localhost/site/test :工作

使用 cUrl 加载:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/site/test");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);

$output -> 来自 apache 的 404 页面

有人知道为什么 cUrl 返回 404 消息吗?

4

1 回答 1

0

原来这与 mod_rewrite 无关。
URL 中的一个目录中有一个空格,我在调用 cUrl 函数时没有对其进行编码。将所有空间替换为 %20 后,一切正常。

主题关闭。

于 2012-04-22T17:30:07.830 回答