Skip to content

Instantly share code, notes, and snippets.

@johnny13
Forked from petertoi/nginx-wp-rewrite-uploads.conf
Last active January 18, 2018 21:16
Show Gist options
  • Save johnny13/741e2687cbc1294ec14b3afbc59baa94 to your computer and use it in GitHub Desktop.
Save johnny13/741e2687cbc1294ec14b3afbc59baa94 to your computer and use it in GitHub Desktop.
Nginx rewrite to request WordPress uploads from external domain
server {
listen 80;
listen 443 ssl http2;
server_name .myriad.app;
root "/home/vagrant/code/myriad";
index index.html index.htm index.php;
charset utf-8;
# location / {
# try_files $uri $uri/ /index.php?$query_string;
# }
location ~ ^/wp-content/uploads/(.*) {
if (!-f $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ https://myriadmobile.com/wp-content/uploads/$1 redirect;
}
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /home/vagrant/log/nginx-myriad.app-error.log error;
# . . . . . . .
# . yada yada .
# . . . . . . .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment