Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Would it be possible to host wp-content on another domain, so that all the uploads and images would go and load from there? If so, how would I go about configuring wordpress to do this, preferably without using a third-party plugin?

share|improve this question
    
Your question as it is now (1. Jun. 2012, 6:00 UTC) doesn’t say anything about another server, so the answer by Aahan Krish is correct. If you want use a real CDN you should use our search. Next time prepare your question better. Oh, and welcome to WordPress Stack Exchange! –  toscho Jun 1 '12 at 6:12
    
True, I wasn't very clear at all; that by other domain I meant other domain that also was on another server. –  messerschmidt Jun 1 '12 at 11:06
add comment

3 Answers

up vote 4 down vote accepted

In WordPress Dashboard > Settings > Media and fill the field "Full URL path to files" with your other domain. See the screenshot below:

Media Settings

EDIT: I thought it would be obvious, but it isn't. Here's what you exactly need to do:

  1. You should map your domain to point to:

    1. public_html directory, IF it's also your WordPress installation's root directory.

    2. public_html/subdirectory/ directory, IF your WordPress installation is in its own subdirectory.

    3. If you have a custom path set in "Store uploads in folder", then your domain should point to the directory ABOVE the custom uploads directory.

      For instance, lets consider this is how your settings are:

      Store uploads in this folder:media/uploads/
      (implies public_html/media/uploads/ directory -- which is, as you guessed it, outside your WordPress installation directory)

      Full URL path to files:http://newdomain.com

      Then, you should make sure, http://newdomain.com points to public_html/media/uploads/ directory.

  2. Now, add the domain (or sub-domain) in the field shown in the screenshot above. Simply adding the domain, without mapping it to your WP installation, won't do the job.

If you don't know how to point your domain, it's a totally different question, and is out of the scope of Wordpress.StackExchange. Google it, you should definitely get your answers. :)


And as for hosting your images on a different server and different domain, you have no better choice than W3 Total Cache <-- yes, a caching plugin for WordPress.

share|improve this answer
    
Great! thank you. If I were to use a web service such as Amazon's cloudfront, how would the method differ? –  messerschmidt May 31 '12 at 19:01
    
@messerschmidt Ah... it's a completely different story. You'd have to use a plugin for that -- the best one I know is a caching plugin that does that > W3 Total Cache –  its_me May 31 '12 at 19:15
    
Cheers! I thought as much. The above method should be sufficient for me, but I'm curious to try a CDN in the future –  messerschmidt May 31 '12 at 19:33
1  
@Tommix Stay polite or stay away. Please. –  toscho Jun 1 '12 at 6:22
1  
@Tommix The question is about a different domain, not a different server. Even if your interpretation were correct there would be no excuse for derogatory comments. –  toscho Jun 3 '12 at 21:47
show 7 more comments

Paste this to your .HTACCESS file:

Header unset ETag
FileETag None

# BEGIN Expire headers  
<ifModule mod_expires.c>  
    ExpiresActive On  
    ExpiresDefault "access plus 35 seconds"  
    ExpiresByType image/x-icon "access plus 2592000 seconds"  
    ExpiresByType image/jpeg "access plus 2592000 seconds"  
    ExpiresByType image/png "access plus 2592000 seconds"  
    ExpiresByType image/gif "access plus 2592000 seconds"  
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"  
    ExpiresByType text/css "access plus 604800 seconds"  
    ExpiresByType text/javascript "access plus 216000 seconds"  
    ExpiresByType application/javascript "access plus 216000 seconds"  
    ExpiresByType application/x-javascript "access plus 216000 seconds"  
    ExpiresByType text/html "access plus 600 seconds"  
    ExpiresByType application/xhtml+xml "access plus 600 seconds"  
</ifModule>  
# END Expire headers  

# BEGIN Cache-Control Headers  
<ifModule mod_headers.c>  
    <filesMatch "\.(ico|jpe?g|png|gif|swf)$">  
        Header set Cache-Control "public"  
    </filesMatch>  
    <filesMatch "\.(css)$">  
        Header set Cache-Control "public"  
    </filesMatch>  
    <filesMatch "\.(js)$">  
        Header set Cache-Control "private"  
    </filesMatch>  
    <filesMatch "\.(x?html?|php)$">  
        Header set Cache-Control "private, must-revalidate"  
    </filesMatch>  
</ifModule>  
# END Cache-Control Headers

This will tell browser to cache all javascript, images, css to computer, so images won't be downloaded from you until they changes. You can use Best browser- chrome to test it with ctrl+shift+j in timeline you can actually see how much time took to download images, the cached ones usually takes 25 ms (cause server first have to say: files is not changed so use the local copy :) )

share|improve this answer
    
This is all good, but how would I go about configuring wordpress so that it will upload the files to the second domain, and then also read from it? –  messerschmidt May 31 '12 at 20:41
add comment

My second aswer:

to use other server it's not easy, to use your subdomain, lets say media.domain.com it's not hard, once i used it in my price compare site done with WP. The main sthing to speed up loadin times is to use diferent domains, and subdomains is good to, cause browsers will open new connection for them too. So use this tutorial: http://www.computingunleashed.com/host-images-in-sub-domain.html

Server will be the same, bat browser will create new connection to load images, so loading times will be shorter (if server is not slow).

share|improve this answer
    
Thanks! But I'm really looking to host the files on a completely different location, due to various reasons. I gather this is difficult, but still possible? –  messerschmidt May 31 '12 at 20:44
    
Well everything is possible, but i don't know answer. it's hard, cause file uploading is LOCAL stuff, and there have to be a lot of modifications to reupload files to remote server. –  Tommixoft May 31 '12 at 20:45
    
That's unfortunate... I had hope you'd be able to use something like mod_rewrite to change the location of the wp-content directory. –  messerschmidt May 31 '12 at 20:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.