im working on a home automated system and the webserver is acting weird

If this is an Uno, you should leave D10-D13 alone. I see you might have something connected (or plan on it) to D10. A relay maybe?

And this is not right.

Ethernet.begin(mac, ip, gateway, subnet);
// it should be
Ethernet.begin(mac, ip, gateway, gateway, subnet);

The first gateway parameter is actually for the dns server ip, but the gateway works ok if you do not plan on using dns.