Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeel-raza/67a6c7eb42ef377824bd8758776bae93 to your computer and use it in GitHub Desktop.
Save adeel-raza/67a6c7eb42ef377824bd8758776bae93 to your computer and use it in GitHub Desktop.
Map uploads dir on local system to remote server

Nginx

Put this within server { ... } block of your vhost

location ~ "^(.*)/your_uploads_folder/(.*)$" {
    if (!-e $request_filename) {
        return 302 http://yourlivesite.com$request_uri;
    }
}

Apache

Place it under wp-content/uploads/ directory

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteBase /your_uploads_folder/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*) http://yourlivesite.com/your_uploads_folder/$1 [L,P]

</IfModule>

Source

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