Skip to content

Instantly share code, notes, and snippets.

@leek
Last active May 4, 2024 07:47
Show Gist options
  • Save leek/b764c44efdf8b7ddb6953039721be69f to your computer and use it in GitHub Desktop.
Save leek/b764c44efdf8b7ddb6953039721be69f to your computer and use it in GitHub Desktop.
Rewrite WordPress Uploads on Local Environment using Nginx or Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$
RewriteRule ^(.*)$ https://<DOMAIN>/$1 [QSA,L]
</IfModule>
# Rewrite images on local to production site
location ~ ^/wp-content/uploads/(.*)$ {
try_files $uri @production;
}
location @production {
proxy_pass https://<DOMAIN>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment