Arduino and the internet?

Controlling the Arduino over the internet versus just the local network has nothing to do with the Arduino's code and everything to do with your network setup. Assuming you are using a small home router that provides NAT (Your local IP address is different from your external address), then you would need to configure your router to forward port 80 (or whichever port you are using) to your Arduino. Some ISPs block port 80, so that's something to keep in mind.

How to forward ports on your router depends on the router you are using. Typically, you need to log into the web interface of your router and look for the port forwarding option.