Skip to content

Instantly share code, notes, and snippets.

@styledev
Created June 21, 2018 17:50
Show Gist options
  • Save styledev/214a6565d2ed250856431d33aeca4704 to your computer and use it in GitHub Desktop.
Save styledev/214a6565d2ed250856431d33aeca4704 to your computer and use it in GitHub Desktop.
Apache mod_rewrite.c code for WordPress to load images from a production server if not found locally. Replace https://www.example.com with your production URL.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) https://www.example.com/$1 [QSA,L,C]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment