Skip to content

Instantly share code, notes, and snippets.

@deryckoe
Last active April 13, 2018 18:39
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 deryckoe/8c53fd0bd938fb32d1f0c2a18be7983a to your computer and use it in GitHub Desktop.
Save deryckoe/8c53fd0bd938fb32d1f0c2a18be7983a to your computer and use it in GitHub Desktop.
Remote Upload
#Put this file in wp-content/uploads and modify remote domain.
#Copia este arhivo en wp-content/uploads and modifica el dominio remoto.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://remotedomain.tld/wp-content/uploads/$1 [L,P]
</IfModule>
@deryckoe
Copy link
Author

En el caso de local, tuve que crear un .htaccess así, en la raíz.

# BEGIN WordPress
RewriteEngine On
RewriteBase /

# custom rules for loading server images or any other uploaded media files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^dominio.local$
RewriteRule ^.*/uploads/(.*)$ http://dominioremoto.com/wp-content/uploads/$1 [L,R=301,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

@deryckoe
Copy link
Author

Con nginx, es así:

server {
    server_name  _;
    return 302 $scheme://dominio.local$request_uri;
}

server {

    # Directives to send expires headers and turn off 404 error logging.
    location ~* \.(js|css|png|jpe?g|gif|ico)$ {
        expires 24h;
        log_not_found off;
        try_files $uri $uri/ @production;
    }

    location @production {
        resolver 8.8.8.8;
        proxy_pass https://dominioremoto.com/$uri;
    }

    server_name ~^(.*)\.dominio\.local$ dominio.local;
    root /app/public/;

    index index.php index.html index.htm;

}

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