Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save viktorbijlenga/8950ece4c8498a21346c665927ddbca7 to your computer and use it in GitHub Desktop.
Save viktorbijlenga/8950ece4c8498a21346c665927ddbca7 to your computer and use it in GitHub Desktop.
htaccess - Redirect image and file request from the localhost to the production host - Wordpress
# Place on top of Wordpress own redirect rules
# If a file (-f) or directory (-d) doesn't exist on the local host,
# A 302 redirect request is made to the production host.
<IfModule mod_rewrite.c>
RewriteEngine On
#Redirect WordPress uploads
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule wp-content/uploads/(.*)$ http://www.example.com/wp-content/uploads/$1 [R=302,L,NC]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment