How to redirect website images to Live site url's to save downloading all assets to local

Hi guys,

First time poster and user of Local here. First of all, I love it and really can’t wait to dig into all it’s features :slight_smile: I just have a simple (hopefully) question:

How can I set up Local so that I redirect all image url’s to my live site? That way I don’t have to download gigabytes of images to my local computer.

I hope that’s possible? :slight_smile:

Thanks in advance,

Jack

Hi @JackEdwardLyons -

We are so happy you are trying out Local!

Here are a couple resources that should hopefully set it up for you to redirect all image url’s to your live site. Also one important thing to note is that your site will need to be on a custom environment.

https://localbyflywheel.com/community/t/redirecting-requests-to-production-wp-content-uploads/671
https://localbyflywheel.com/community/t/read-remote-upload-folder-with-nginx/5882

Thanks!

Keegan

Hi, I’m trying to do this but where can I find vvv_root/config/nginx-config? When I go to Applications/Local By Flywheel it just opens up the app and make the changes in the link you provided?

If you’re using Local rather than Vagrant, you’ll use the Finder to navigate to ~/Local Sites/name-of-site/conf/nginx/site.conf

This is what I’m using in the latest version of Local:

    location ~* \.(?:jpg|jpeg|gif|png|ico|xml)$ {
    access_log        off;
    log_not_found     off;
    expires           5m;
    add_header        Cache-Control "public";
    try_files         $uri $uri/ @production;
}

location ~* \.(?:eot|woff|woff2|ttf|svg|otf) {
    access_log        off;
    log_not_found     off;

    expires           5m;
    add_header        Cache-Control "public";

    # allow CORS requests
    add_header        Access-Control-Allow-Origin *;
    try_files         $uri $uri/ @production;
}

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

Hope that helps

Hey @JackEdwardLyons

Were you able to get this to work for your use case?

As ColinD mentioned, the configuration is slightly different between Local and VVV. The only other thing that I would add is that the configuration files are only accessible in Finder if you are using a Custom environment.

Preferred environments can’t be edited as easily, so you might consider cloning the site from the preferred environment to a custom one in order to make this work.

1 Like

Hi thanks for the reply, but no I wasn’t able to get this working. I’m not sure what files I need to change exactly. Where do I go in Local / where in finder do I go?

Thank you

image.png

image.png

image.png

image.png

Hey @JackEdwardLyons

The big thing is to ensure that it’s a Custom environment. If it is, then all you have to do is right click on the site and open it in a file explorer. From there, navigate to site-folder/conf/nginx/site.conf and make the changes there!

You might need to stop and restart the site in order to reload the configuration changes, but that should get you in the right direction!