Skip to content

Instantly share code, notes, and snippets.

@thetwopct
Created May 22, 2021 05:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetwopct/7fef629cf0206cf9642be9c42b28730a to your computer and use it in GitHub Desktop.
Save thetwopct/7fef629cf0206cf9642be9c42b28730a to your computer and use it in GitHub Desktop.
WordPress - Using .htaccess to load images from production server
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# If images not found on development site, load from production
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp-content/uploads/[^/]+/.+\.(jpe?g|jpg|png|gif)$ https://production.com/$0 [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment