WordPress .htaccess File Settings For Image Hotlinking

http://stevegrunwell.github.io/wordpress-git/#/

This code can be used inside local wordpress website development (root directory) to link to images from the live/ production site. The code just redirects all internal links referenced from the ‘wp-contents/uploads' folder to the same folder from the live/production site.

This usage can be used when you have images that have been uploaded to the live server from users etc. but are not on the local development server. If the live server is downloaded to the local server (for example, Git/FTP), then it is not necessary to also download all of the images when the .htaccess code below is used.

Note that there are actually only 2 lines added to the end of the code (before </IfModule>)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /superlist4/index.php [L]
RewriteRule wp-content/uploads/(.*) \
  https://{enter-domain-name}/wp-content/uploads/$1 [NC,L]
</IfModule>

# END WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.