Update 2/24/2009: This method is deprecated. I wrote a plugin to rewite urls.
Update again: SimpleCDN is slower comparing to CloudFront, I moved all my link to CF. If you have problem copying files to S3, you can read this post.
WordPress is my favorite bloging software, with many builtin features and powerful plugins. WordPress.com, the blogging platform by automattic, has been using CDN for a long time. However there is no public available solution to make self hosted WordPress to use a CDN as well. Fortunately the php code itself is very clean to read, so it took me about 5 minutes to find where I should modify to fully integrate my new CDN address.
Once your DNS full propagated, open your favorite text editor open following 3 files.
‘wp-includes/class.wp-scripts.php‘: near line 75, change
$src = $this->base_url . $src;
$src = 'http://yourcdnbucketname' . $src;
There is no trailing slash after your bucketname. If you want to make sure client browser always use cached version, you can also comments out the following line.
// $src = add_query_arg('ver', $ver, $src);
But this change may break WordPress upgrade.
‘wp-include/class.wp-styles.php‘: near line 79, do the same change as above.
‘wp-include/theme.php‘: near line 504, change
return apply_filters('theme_root_uri', content_url('themes'), get_option('siteurl'));
That’s it. Now clean your cache and test your blog.