Skip to content

Instantly share code, notes, and snippets.

@cobbman
Last active June 27, 2016 18:12
Show Gist options
  • Save cobbman/dfb885a959840b7b436f46a58504fbc9 to your computer and use it in GitHub Desktop.
Save cobbman/dfb885a959840b7b436f46a58504fbc9 to your computer and use it in GitHub Desktop.
Checks for local files in wp-content/uploads and rewrites the URL to the live server if needed. Also checks that the HOST is local, so it won't run outside of your dev URL.
// Place this BEFORE the WordPress Rewrite rules
// Be sure to edit LOCALHOST and LIVESITE with the proper URL's
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{HTTP_HOST} ^LOCALHOST\.dev$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://LIVESITE.com/$1 [R,L,NC]
</IfModule>
@sgreer81
Copy link

Just used this. It is sweet!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment