Setup a separate sub-domain for media files in WordPress

Optimise your WordPress site by hosting your assets in a separate sub domain.

You can move everything in your wp-content to a separate domain or sub-domain (for example: media.example.com ) hosted in the same server. For this, create a sub-domain first, using your web control panel or by editing apache configuration and adding A records to DNS manually. After DNS propagated, copy all directories from your existing wp-content to the document root of your new (sub)domain. Set WP_CONTENT_DIR and WP_CONTENT_URL in your wp-config.php

define('WP_CONTENT_DIR', '/home/user/domain/example.com/media');
define('WP_CONTENT_URL', 'http://media.example.com');

See Moving wp-content in WordPress Codex for more information.

Login to WordPress as administrator user, make sure that the correct theme is selected and change the uploads directory path and URL path ( Settings > Miscellaneous ).

Image showing how to change uploads directory and URL paths

Note: Some plug-in developers don’t use WP_CONTENT_DIR, WP_CONTENT_URL constants, causing their plug-ins to get broken. The workaround, in this case, is correcting the plug-in files yourself.

See Web Site Optimization: 13 Simple Steps to know more about site optimisation techniques.

See how to move your WordPress feeds to a separate (sub)domain.

See the previous post, How to remove cruft from your apache log

Or get RSS feed

Author: Syam Kumar R

Syam Kumar is an independent Web Developer based in Cochin, India. His interests include information design concepts, standards compliant web development and Linux. He administers WebMaster View.

This entry was posted on Saturday, November 28th, 2009 at 12:41 am and modified by webmasterview on Wednesday, December 2nd, 2009 at 1:47 am. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Pings/Trackbacks: 2

  1. Setup a separate sub-domain for media files in WordPress … Webmaster World
  2. untell.com

RSS feed

follow

Be a Fan

Bad Behavior has blocked 1305 access attempts in the last 7 days.