Hi, I am not sure if I am in the right section, so admins please move me if I am not. I am making a POST request using curl to one of the .php files on my server. The url is of form: http://myserver.com/php/form.php
When I try to make the request on my laptop running XAMPP, the request executes just fine, but when I run the same code on my hosting company's dedicated virtual box curl returns status of 404, page "http://myserver.com/php/form.php" not found. However if I put in that url in my browser's window, the browser can find it just fine. Does anybody know what's going on? Is it my php.ini, iptables rules, or what?
Thanks.
cURL returning a 404
Moderator: General Moderators
-
jonwondering
- Forum Commoner
- Posts: 39
- Joined: Mon Mar 13, 2006 6:26 pm
Re: cURL returning a 404
Update: Just checked headers, and it's probably not the firewall. Here's the headers:
Still no idea what's going on. Any suggestions?
Code: Select all
* About to connect() to myserver.com port 80
* Trying 127.0.0.1... * connected
* Connected to myserver.com (127.0.0.1) port 80
> POST /php/form.php HTTP/1.1
Host: myserver.com
Accept: */*
Content-Length: 6
Content-Type: application/x-www-form-urlencoded
test=1
< HTTP/1.1 404 Not Found
< Date: Wed, 14 Jan 2009 18:31:24 GMT
< Server: Apache
< Content-Length: 223
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
* Closing connection #0-
jonwondering
- Forum Commoner
- Posts: 39
- Joined: Mon Mar 13, 2006 6:26 pm
Re: cURL returning a 404
okay, got it. found solution in one of media temple's private forums, here's a quote:
For me it worked to change request from "http://myserver.com/php/form.php" to "http://xx.xx.xx.xx/php/form.php" where the X's are the actual IP of my server (not 127.0.0.1). Hope this helps someone too... Cheers.Howdy, I've kinda figured out the problem here. Tech support says that curl looks in the hosts file for dns resolution first. Then it goes out and tries dns. curl finds an entry in the hosts file for my domain but it's 127.0.0.1
That doesn't get to where I want it to go. So, I go and modify the hosts file for my ip address and my domain. Should work right? Should, I'm trying that now.