Я - разработчик Android, имеющий очень мало знания PHP. Я застреваю с этой проблемой получения 404 Ошибочных Объектов, Не Найденных, читая переменные от строки запроса. Я добавил .htaccess файл в результате, ошибка уходит, но переменные не прочитаны. Хотя, если я прочитал URL без строки запроса, это работает отлично. Я не могу думать о причине, она не должна работать. Вот то, что я попробовал:
Файл PHP:
Название файла: file_getTest.php
function file_get_contents_curl($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$baseUrl='http://xyz.com?language=en';
$language = $_GET['language'];
$session = $_GET['sessionID'];
$placeOrigin=$_GET['place_origin'];
$typeOrigin=$_GET['type_origin'];
$nameOrigin=$_GET['name_origin'];
$homePage =($baseUrl."&sessionID=".$session."&place_origin=".$placeOrigin."&type_origin=".$typeOrigin."&name_origin=".$nameOrigin);
//if "echo file_get_contents($baseUrl)" is executed it works fine
//echo file_get_contents($homePage); //I have tried file_get_contents but no use
echo file_get_contents_curl($homePage);
Кодекс .htaccess:
RewriteEngine on
RewriteRule .* file_getTest.php
Without .htacess file & using curl() I get this error:
The requested URL /test/file_getTest.php&sessionID=value read&place_origin=value read&type_origin=value read&name_origin=value read was not found on this server.
With .htaccess file & using curl() I get the following error:
Объект HTTP/1.1 404, Не Найденный
Without .htacess file & using file_get_contents() I get this error:
The requested URL /test/file_getTest.php&sessionID=value read&place_origin=value read&type_origin=value read&name_origin=value read was not found on this server.
With .htaccess file & using file_get_contents() I get the following error:
file_get_contents(http://xyz.com?language=en&sessionID=&place_origin=&type_origin=&name_origin=): failed to open stream: HTTP request failed! Объект HTTP/1.1 404, Не Найденный in C:\wamp\www\file_getTest.php on line 20
I would greatly appreciate any help. I have been stuck on this issue for some time now & can't seem to find a solution.