Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@noelboss
Last active May 22, 2020 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelboss/aa7422c75fe8ec8b920d67666e01381b to your computer and use it in GitHub Desktop.
Save noelboss/aa7422c75fe8ec8b920d67666e01381b to your computer and use it in GitHub Desktop.
Serve files from server when not available on your local machine
# Get all wp-content files from remote if localy not available (Perfect for local development environment
# Determine environment
# Local
SetEnvIf Server_Addr ^\:\:1 WPENV=local
SetEnvIf Server_Addr ^127\.0\.0\.1 WPENV=local
SetEnvIf Host ^(www\.)?local\. WPENV=local
# Release
SetEnvIf Host ^(www\.)?dev\. WPENV=release
SetEnvIf Host ^(www\.)?release\. WPENV=release
<IfModule mod_rewrite.c>
RewriteEngine On
# Rewrite only non existing files
RewriteCond %{REQUEST_FILENAME} !-f [NC]
# only when local or on release system
RewriteCond %{ENV:WPENV} ^(local|release)$
# only when in uploads folder
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
# add your domain:
RewriteRule ^(.*)$ https://www.your-domain.com/$1 [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment