cURL returning a 404

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonwondering
Forum Commoner
Posts: 39
Joined: Mon Mar 13, 2006 6:26 pm

cURL returning a 404

Post by jonwondering »

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.
jonwondering
Forum Commoner
Posts: 39
Joined: Mon Mar 13, 2006 6:26 pm

Re: cURL returning a 404

Post by jonwondering »

Update: Just checked headers, and it's probably not the firewall. Here's the headers:

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
Still no idea what's going on. Any suggestions?
jonwondering
Forum Commoner
Posts: 39
Joined: Mon Mar 13, 2006 6:26 pm

Re: cURL returning a 404

Post by jonwondering »

okay, got it. found solution in one of media temple's private forums, here's a quote:
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.
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.
Post Reply