Require login for the WordPress Media Folder
|
Usage When you enable this option, WPO365 blocks direct access to your WordPress site's Media Library, i.e. the /wp-content/uploads folder. Every request for a file in /wp-content/uploads is routed to WPO365's so-called secure download proxy instead. WPO365 does this by adding rewrite rules to your website's .htaccess file (see info box immediately below the "Usage" section if your site uses another web server that ignores WordPress' default .htaccess file.
|
IMPORTANT
|
Secure Download Mode
- PHP This is the default mode. Files are served directly by PHP after the plugin has verified that the user is authorized to access the requested file.
- Use X-Sendfile (Apache) When enabled, the plugin instructs the Apache web server to serve the file using the X-Sendfile response header. This can significantly reduce PHP memory usage and improve the handling of large downloads.
- Use X-LiteSpeed-Location (LiteSpeed) When enabled, the plugin instructs the LiteSpeed web server to serve the file using the X-LiteSpeed-Location response header. This can improve performance and allows the web server to handle file delivery directly.
|
IMPORTANT Only enable a hand-off mode if your server is configured to support the corresponding response header. For example, when using X-Sendfile with Apache, the mod_xsendfile module must be installed and enabled. If the required server support is not available, file downloads may fail. A good indication that the header is not supported by your server is when you see the X-Sendfile as part of the raw response. |
Instructions for Apache (.htaccess)
Please try and operate the toggle as illustrated below first.
If an error is returned, then please try and update your site's .htaccess manually instead, by adding the lines below to the end of the file.
Single Site
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
RewriteRule ^wp-content/uploads/(.*)$ /wp-content/plugins/wpo365-login/Services/Secure_Download_Proxy.php?file=$1 [L,QSA]
</IfModule>
Multi-Site
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(?:[_0-9a-zA-Z-]+/)?wp-content/uploads/(.*)$ /wp-content/plugins/wpo365-login/Services/Secure_Download_Proxy.php?file=$1 [L,QSA] </IfModule>
Instructions for NGINX
Single Site
In your server block, add the following config.
location ~* ^/wp-content/uploads/(.*)$ {
rewrite ^/wp-content/uploads/(.*)$ /wp-content/plugins/wpo365-login/Services/Secure_Download_Proxy.php?file=$1 last;
}
location ~ ^/(?:[_0-9a-zA-Z-]+/)?wp-content/uploads/(.*)$ {
rewrite ^/(?:[_0-9a-zA-Z-]+/)?wp-content/uploads/(.*)$ /wp-content/plugins/wpo365-login/Services/Secure_Download_Proxy.php?file=$1 last;
}
- Put it before any location that matches static files by extension, e.g. location ~* \.(jpg|jpeg|png|gif|webp|svg|pdf)$ { expires max; }. Most WordPress NGINX configs have one. If that block comes first, images and PDFs are served directly and aren't protected.
- Put it after any location that denies access to part of uploads, e.g. WooCommerce's woocommerce_uploads folder, or a rule that blocks PHP in uploads. Otherwise, this rule overrides them.
- Don't use location ^~ /wp-content/uploads/ to avoid the ordering problem: it also skips those deny rules.
Instructions for IIS / Azure App Service
<rewrite>
<rules>
<rule name="Secure Uploads" stopProcessing="true">
<match url="^wp-content/uploads/(.*)$" />
<action type="Rewrite" url="/wp-content/plugins/wpo365-login/Services/Secure_Download_Proxy.php?file={R:1}" />
</rule>
</rules>
</rewrite>
Versions ESSENTIALS, PROFESSIONAL, INTEGRATE, CUSTOMERS (SYNC, INTRANET)
Visit the website https://www.wpo365.com/