How to redirect WordPress images to a different domain (with htaccess)

The question is quite simple, you are on a development website (also locally) but you don’t care of the images (maybe because they are 50000~)!
A simple solution is a Apache redirect for your .htaccess (to put before the section added by WordPress), in this way the local request (on remote if it is a staging) get a redirect to the image.

RewriteEngine on
RewriteRule ^(wp-content/uploads/.*)$1 [L]

In this example we have a domain with the WP instance in a subfolder but in case you don’t are in this case just remove the blog/ part.

Liked it? Take a second to support Mte90 on Patreon!
Become a patron at Patreon!

Leave a Reply

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