[SOLVED] Shield Ethernet as web client : 404 error


I’m working with the shield Ethernet.
I succeeded in using it as a web server, and it’s cool.

Now I’m trying to use it as a web client.
It seems it succeeds in connecting to the web, but I keep receiving error pages, like 404 error page.

The page I want the Arduino to get is : www.antoinev2.com/0/LogDebug/page.php.
If you try this in your browser, you’ll see that :

The sketche is the following :

// application : Ethernet ; web client
// Ethernet_V0_08.ino
// 2015/03/23

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0x90, 0xA2, 0xDA, 0x07, 0x00, 0xA1};
char serverName[] = "www.antoinev2.com";
EthernetClient client;
float value;
boolean connecte = false;

void setup()
    Serial.println(F("Oh yeah !!"));
    if (Ethernet.begin(mac) == 0) {
        Serial.println(F("Echec configuration Ethernet par DHCP."));
    } else {
        Serial.println("connexion en cours...");
        int ret = client.connect(serverName, 80);
        if (ret == 1) {  
            Serial.println("connexion ok.");
            connecte = true;
            client.println("GET /0/LogDebug/page.php HTTP/1.0");
        } else {
            Serial.println("connexion echouee, erreur : ");
            Serial.print(ret, DEC);

void loop() {
    if (connecte) {
        if (client.available()) {
            char c = client.read();
        if (!client.connected()) {
            connecte = false;

The result displayed in the serial monitor :

Oh yeah !!
connexion en cours...
connexion ok.
HTTP/1.0 404 Not Found
Date: Mon, 23 Mar 2015 22:36:38 GMT
Server: LiteSpeed
Connection: close
Content-Type: text/html
Content-Length: 1974
Vary: User-Agent

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <title>404 Not Found</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        body {
        	font-family: Verdana, Arial, Helvetica, sans-serif;
        	font-size: 12px;
        	scrollbar-base-color: #005B70;
        	scrollbar-arrow-color: #F3960B;
        	scrollbar-DarkShadow-Color: #000000;
        	color: #FFFFFF;
        a { color:#021f25; text-decoration:none}
        h1 {
        	font-size: 18px;
        	color: #FB9802;
        	padding-bottom: 10px;
        	background-image: url(sys_cpanel/images/bottombody.jpg);
        	background-repeat: repeat-x;
        	padding:5px 0 10px 15px;
        #body-content p {
        	padding-left: 25px;
        	padding-right: 25px;
        	line-height: 18px;
        	padding-top: 5px;
        	padding-bottom: 5px;
        h2 {
        	font-size: 14px;
        	font-weight: bold;
        	color: #FF9900;
        	padding-left: 15px;
    <div id="body-content">  
<!-- start content-->

 instead of REQUEST_URI, we could show absolute URL via:
    but what if its https:// or other protocol?
    SERVER_PORT_SECURE doesn't seem to be used
    SERVER_PORT logic would break if they use alternate ports

<h1>404 Not Found</h1>
<p>The server can not find the requested page:</p>
    /0/LogDebug/page.php (port 80)
    Please forward this error screen to 's 
    <a href="mailto:admin@planethoster.info?subject=Error message [] 404 Not Found for /0/LogDebug/page.php port 80 on Monday, 23-Mar-2015 23:36:38 CET">
<hr />

Some facts :
I use DHCP, and DNS resolution.
My website at Planet Hoster is on a shared hosting.

Any idea ?

A virtual server requires a host parameter in the request header, like this:

            client.println("GET /0/LogDebug/page.php HTTP/1.0");
            client.println("Host: www.antoinev2.com");


thank you so much SurferTim!

I didn't know that shared hosting implies the use of virtual hosting with Apache, I'm aware of it now.
I've got to use HTTP 1.1 instead of HTTP 1.0 for my sketche to work, it seems HTTP 1.0 doesn't allow the "Host" header.

So, if somebody else needs it, the following method is ok :

client.println("GET /0/LogDebug/page.php HTTP/1.1");
client.println("Host: www.antoinev2.com");