Skip to content

Instantly share code, notes, and snippets.

@ksemel
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksemel/6c013fe2d592fa629fea to your computer and use it in GitHub Desktop.
Save ksemel/6c013fe2d592fa629fea to your computer and use it in GitHub Desktop.
Run your WordPress site locally without copying down all your images
# BEGIN WordPress
<IfModule mod_rewrite.c>
# Single site Rules (with image pass-back)
###################################################
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# if it is an image that doesn't exist, try prod
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp-content/uploads/(.*)$ http://[YOUR PRODUCTION SITE]/wp-content/uploads/$1 [R=301,L]
# if request is for image, css, or js file
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^ - [S=1]
# else rewrite the request to WP
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