Skip to content

Instantly share code, notes, and snippets.

@fsgreco
Created December 31, 2022 17:48
Show Gist options
  • Save fsgreco/037f4df9fb36732dff8a0ac358524c8a to your computer and use it in GitHub Desktop.
Save fsgreco/037f4df9fb36732dff8a0ac358524c8a to your computer and use it in GitHub Desktop.
Htaccess for WordPress local development - it let you visualize upload files (from production) in your localhost environment
# MIT © Santiago Greco - fsgreco@hey.com
#
# What it does:
# If the site is already in production, instead of manually download all the files in upload folder
# your local apache server will search and use the production files if they are not found on localhost
#
# How to use it:
# Place this file inside your own localhost environment: `your_localhost/wp-content/uploads/.htaccess`
# Change "YOUR_DOMAIN.TLD" with your actual production domain name inside the RewriteRule line.
#
# For more context and information please consult the documentation of the entire project:
# docker-wordpress - https://github.com/fsgreco/docker-wordpress#how-to-use-it
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Change YOUR_DOMAIN.TLD with your actual production domain
RewriteRule (.*) https://www.YOUR_DOMAIN.TLD/wp/wp-content/uploads/$1
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment