I have Wordpress website which is live. In this website are a lot of posts with uploads over 200GB. I want to create in localhost development environment which I have done, but I have problems with posts images, because I don't want to download all of them and put in my localhost. So I am wondering if there is any Nginx rewrite rule which will rewrite only domain name in my image urls.
I need to rewrite this url:
https://example.local/wp-content/uploads/2020/10/10/very-nice-picture.png
To this one:
https://example.com/wp-content/uploads/2020/10/10/very-nice-picture.png
This is possible with Nginx or there is other better solution?
Here are your options:
Use a redirection:
location /wp-content/uploads/ { return 301 http://example.com$request_uri; # or use 302 to prevent redirection caching }
Use transparent proxying:
location /wp-content/uploads/ { proxy_pass http://example.com; }
You can also use remote files only in case they are missing on the local development server:
location /wp-content/uploads/ {
try_files $uri @remote;
}
location @remote {
# redirect or proxy the request as shown above
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.