Back to Community

Resolving .htaccess Issues and Configuration Problems in WebP Express

14 threads Sep 10, 2025 PluginWebp express

Content

WebP Express is a powerful tool for serving next-generation WebP images on your WordPress site. However, its reliance on server configuration files, primarily .htaccess, can sometimes lead to conflicts, errors, or simply not work on certain hosting environments. This guide covers the most common configuration and server-related issues and how to resolve them.

Common .htaccess Related Problems

Many issues arise from how and where WebP Express writes its rewrite rules. Based on community reports, these are the frequent pain points:

  • Hosting Restrictions: Some hosts disallow the SetEnv directive or block .htaccess files entirely (Threads 1, 12).
  • Incorrect File Paths: A bug can sometimes cause double slashes (e.g., //path//to/file) to appear in the generated rules, breaking them (Thread 4).
  • Rule Overwrite: Manually added rules in .htaccess can be overwritten when reactivating the plugin or clicking "Save settings and force new .htaccess rules" (Thread 7).
  • Non-Apache Servers: The plugin's .htaccess rules are designed for Apache and do not work on servers like Nginx, Caddy, or Lighttpd (Threads 3, 11, 12).
  • Cache-Control Headers: Custom cache headers like stale-while-revalidate require using the "Custom" setting, not the predefined dropdown options (Thread 6).

Solutions and Workarounds

1. For Hosts That Block .htaccess or SetEnv

If your host blocks SetEnv, you can manually add the necessary headers. The WebP Express team suggests creating or editing the .htaccess file in your uploads directory (or the mingled destination folder) with the following rules:

<IfModule mod_headers.c>
  <FilesMatch ".webp$">    
    Header append "Vary" "Accept"
  </FilesMatch>
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch ".(jpe?g|png)$">    
    Header append "Vary" "Accept"
  </FilesMatch>
</IfModule>

2. For Non-Apache Servers (Nginx, Caddy, Lighttpd)

WebP Express generates Apache rules. For other servers, you must manually translate these rules into your server's configuration syntax. There is no automatic conversion within the plugin. You will need to:

  1. Configure WebP Express for "Redirection to converter" instead of using rewrite rules.
  2. Consult your server's documentation to manually implement the redirection logic.

3. Using WebP Express Without Redirection

You can use the plugin solely for generating WebP images without any delivery/redirection rules. To do this, set the Operation mode to "Just generate" or choose a redirection method that uses PHP instead of .htaccess rules, such as "Via PHP." This avoids writing any server rules altogether (Thread 5).

4. Preventing Configuration Loss on Deployment

WebP Express saves its settings in the WordPress database, not in files. If your settings are lost during deployment, ensure your deployment process includes migrating the WordPress database. The specific options are stored in the wp_options table (Thread 2).

5. Viewing .htaccess Rules for Manual Configuration

For security-conscious users or custom server setups (like Bedrock), you may wish to manually add the rules to your main server config. The plugin generates these rules in the .htaccess files within your wp-content and uploads directories. You can copy the rules from these files after WebP Express creates them. A feature to view these rules directly in the plugin's admin area has been suggested but is not currently available (Thread 10).

Conclusion

While WebP Express is designed to be as automated as possible, certain server environments require manual intervention. Understanding how it interacts with .htaccess files and knowing the available workarounds is key to a successful implementation. For ongoing issues, checking the official GitHub repository for the plugin is recommended for the latest updates and community discussions.

Related Support Threads Support