Last active
May 22, 2020 12:34
-
-
Save noelboss/aa7422c75fe8ec8b920d67666e01381b to your computer and use it in GitHub Desktop.
Serve files from server when not available on your local machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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