This configuration will set up a proxy on Apache to serve files from the production server when they are not available locally in the wp-content/uploads/
directory. This might be useful if you want to perform partial syncs using LocalWP.
-
Open Apache Configuration File
Open the Apache configuration file for editing. This file is usually located at
C:\Users\user\Local Sites\{{your-project}}\conf\apache
on Windows. -
Add Proxy Configuration
Add the following configuration to the
httpd.conf.hbs
file within the<VirtualHost>
block.<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} ^example\.test$ RewriteRule ^wp-content/uploads/(.*)$ https://example.com/wp-content/uploads/$1 [NC,L] </IfModule>
-
Save and Close the File Save the changes and close the editor.
-
Reload Apache Reload Apache from the LocalWP dashboard to apply the new configuration.
<IfModule mod_rewrite.c>
: This block ensures that the rewrite rules are only applied if the mod_rewrite module is enabled.RewriteEngine on
: Enables the runtime rewriting engine.RewriteBase /
: Sets the base URL for per-directory rewrites.RewriteCond %{REQUEST_FILENAME} !-f
: This condition checks if the requested filename does not exist as a file.RewriteCond %{HTTP_HOST} ^example\.test$
: This condition checks if the HTTP host matches example.test.RewriteRule ... [NC,L]
: This rule rewrites requests for files in the wp-content/uploads directory to the production server (https://example.com). The [NC] flag makes the rule case-insensitive, and the [L] flag indicates that this is the last rule to be processed if it matches.