Skip to content

Instantly share code, notes, and snippets.

@celsowhite
Last active July 12, 2019 19:49
Show Gist options
  • Save celsowhite/af93527b2833ea4867a77b9910fba28b to your computer and use it in GitHub Desktop.
Save celsowhite/af93527b2833ea4867a77b9910fba28b to your computer and use it in GitHub Desktop.
Altered wordpress htaccess file to pull uploads from production
# Load media files from production server if they don't exist locally.
# Below snippet must be placed before wordpress default htaccess rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule wp-content/uploads/(.*) http://production-url.com/wp-content/uploads/$1 [NC,L]
</IfModule>
# Allow CORS (Mainly used for enabling access to files via the REST API)
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods: "GET"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment