Last active
May 4, 2024 07:47
-
-
Save leek/b764c44efdf8b7ddb6953039721be69f to your computer and use it in GitHub Desktop.
Rewrite WordPress Uploads on Local Environment using Nginx or Apache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$ | |
RewriteRule ^(.*)$ https://<DOMAIN>/$1 [QSA,L] | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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