Using CDN to serve images folder for PHP/Apache website

apache-2.2cdn

I have a PHP5/Apache2/MySQL website.
Now in the folder structure under root I have an root\images folder that just has images. I also have a root\skin\images folder again has only images. If I wanted to serve the two images folders over a CDN how would I do this (without changing php etc, just using Apache, possible?)

Currently Apache directly handles all requests to the site. I have root access to the webserver so I can change the setup.

Best Answer

CDNs operate in a way then when a DNS lookup is made, it returns the closest (i.e. fastest) server to the users location. That's why you will find, for example:

http://www.example.com/ = website
http://images.example.com/something.jpg = CDN with images

You'll need to have a different (CDN'd) hostname for your images, I'm afraid.

If you use Apache's mod_substitute, you should be able to replace the images with ones on such a CDN domain so you don't have to make any PHP changes.