How To Host My Wordpress Images On My Other Server

Discussion in 'WordPress' started by T.j. Detwiler, May 20, 2012.

  1. #1
    I want to host my all image from different server and run site on different server is it possible ?
     
    T.j. Detwiler, May 20, 2012 IP
  2. 5Twenty

    5Twenty Peon

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yea this is possible. It's most common when using a CDN to host your image files. You just need to edit your htaccess file. It should look something like this:

    #  RewriteCond %{HTTP_HOST} YOURDOMAINNAME.com
    #  RewriteCond %{REQUEST_URI} [images]/(.*)\.(.*)
    #  RewriteRule (.*) http://static-imgs.YOURDOMAINNAME.com%{REQUEST_URI} [R=301,NC,L]

    As you can see we use the rewrite function to tell the user that the images are stored in a sub-domain. So you will need to create a sub-domain with your registrar and have it pointed to your second server.

    FYI: THIS SNIPPET NEEDS TO GO AFTER THE DEFAULT WP REWRITE CODE IN YOUR HTACCESS FILE. TO MAKE SURE JUST PUT IT AT THE VERY END.
     
    5Twenty, May 21, 2012 IP