Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
Created December 27, 2019 14:07
Show Gist options
  • Save aaronsummers/4539789a03794bc663389c5e1047591e to your computer and use it in GitHub Desktop.
Save aaronsummers/4539789a03794bc663389c5e1047591e to your computer and use it in GitHub Desktop.
redirect localhost images from wordpress to production server
# my local and production sites use /blog/ as a directory for WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/blog/wp-content/uploads/[^\/]*/.*$
RewriteRule ^(.*)$ https://www.example.com/blog/$1 [QSA,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
@aaronsummers
Copy link
Author

This only works with the uploads rewrite above # Begin WordPress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment