Skip to content

Instantly share code, notes, and snippets.

@richardsweeney
Last active December 22, 2015 03:29
Show Gist options
  • Save richardsweeney/6410870 to your computer and use it in GitHub Desktop.
Save richardsweeney/6410870 to your computer and use it in GitHub Desktop.
Proxy requests for files not found to production/staging server. Useful for working with WordPress (or Drupal, or whatever), so you don't have to download all uploaded files when you grab a production database.
RewriteCond %{HTTP_HOST} ([_0-9a-zA-Z-.]+)\.(dev|local)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://example.com/$1 [R=302,L]
@richardsweeney
Copy link
Author

If you were to grab a WP install and DB from a production server. Import the DB, then '$ wp search-replace example.com example.dev' (if that's how you roll). Don't bother downloading all the files in wp-content/uploads/ just use this script to proxy the request to the production server. Mark Jaquith gave me the idea in a cool talk on deploying WordPress - http://wordpress.tv/2013/07/28/mark-jaquith-confident-commits-delightful-deploys-2/.

Legend

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