wckr / wocker

Create your WordPress development environment in 3 SECONDS!
https://wocker.dev/
MIT License
480 stars 42 forks source link

Mock production uploads for parity purposes #83

Open malarstrom opened 5 years ago

malarstrom commented 5 years ago

This isn't obvious to everyone. So here's a tip!

If you'd like to mock the uploads of the production environment of the site you are working on. Then just (so you don't have to use a local copy of the production uploads):

  1. Create ~/data/{CONTAINER}/wp-content/uploads/.htaccess containing (before wp directive):
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.*) http://{PRODUCTION_URI}/wp-content/uploads/$1
    </IfModule>

    All uploads with local file paths will now be served from the production site. If you by any reason have a different structure for the uploads folder, just change it in the rule

Enjoy!