Xampp Curl cant resolve Host

Irgendwelche Probleme mit XAMPP für Windows? Dann ist hier genau der richtige Ort um nachzufragen.

Xampp Curl cant resolve Host

Postby the_cleaner » 23. May 2021 10:50

Hallo

Ich habe hier eine Applikation die ich per Xampp auf einem Windows Rechner laufen habe.

Ich wollte Lokal eine custom url haben. Angepasst in windows host file und xampp httpd-vhosts.conf.
Die Applikation läuft

Wenn ich aber verusche, ein curl call zu machen, kommt die Fehlermeldung Could not resolve host: test.localhost
gebe ich die Url in den Browser ein, erfolgt der Call

Meine Applikation: test.localhost
Der Call: test.localhost/api_call

httpd-vhosts.conf
Code: Select all
<VirtualHost *>
  # Pfad muss angepasst werden
  DocumentRoot C:\xampp\htdocs/sites
  ServerName localhost
</VirtualHost>
<VirtualHost *>
  # Pfad verweist auf Projekt-Ordner
  DocumentRoot "C:\xampp\htdocs/sites/test"
  ServerName test.localhost
  DirectoryIndex index.php
  <Directory "C:\xampp\htdocs/sites/test">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>


hier der CAll den ich versuche

Code: Select all
$url = 'test.localhost/api_call';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
// curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);


weiss jemand was das Problem ist?
the_cleaner
 
Posts: 2
Joined: 23. May 2021 10:36
XAMPP version: 3.3.0
Operating System: Win 10 64

Re: Xampp Curl cant resolve Host

Postby Nobbie » 23. May 2021 17:13

Da fehlt auf alle Fälle mindestens das Netzwerkprotokoll, so kann es nicht funktionieren. Wahrscheinlich willst Du via Protokoll http zugreifen, also müßte die URL entsprechend so aussehen:

Code: Select all
$url = 'http://test.localhost/api_call';


Und dann nochmal probieren.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Xampp Curl cant resolve Host

Postby the_cleaner » 23. May 2021 21:42

ob mit od ohne http, die Fehlermeldung ist gleich
the_cleaner
 
Posts: 2
Joined: 23. May 2021 10:36
XAMPP version: 3.3.0
Operating System: Win 10 64


Return to XAMPP für Windows

Who is online

Users browsing this forum: No registered users and 38 guests