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 is the Owner and Editor of WebMaster View. He is based in Cochin, Kerala, India. His interests include information design concepts, standards compliant web development and Linux.

This entry was posted on Saturday, November 28th, 2009 at 12:41 am and modified by WebMaster View on Wednesday, December 2nd, 2009 at 1:47 am. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

Pings/Trackbacks: 2

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

RSS feed

follow

Be a Fan

Google+ Page