-
-
Save tw2113/64558a5a2969d251a1c677a9a12287fc to your computer and use it in GitHub Desktop.
Update .htaccess to serve local uploads and fallback to prod for missing files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEGIN WordPress | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
RewriteBase / | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
# Only redirect to production if the file does not exist locally | |
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.*)$ | |
RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads/%1 !-f | |
RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads/%1 !-d | |
RewriteRule ^wp-content/uploads/(.*)$ https://yoursite.com/wp-content/uploads/$1 [R=301,L] | |
</IfModule> | |
# END WordPress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment