Skip to content

Instantly share code, notes, and snippets.

@MrCoker
Forked from aaronsummers/.htaccess
Created January 17, 2020 12:14
Show Gist options
  • Save MrCoker/f6a21f14cb6b5acec7cf51e00177f07b to your computer and use it in GitHub Desktop.
Save MrCoker/f6a21f14cb6b5acec7cf51e00177f07b 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment