---
title: File Optimizer Rewrite Rules
description: Serve combined and minified CSS and JavaScript from short /_static/ URLs in WordPress with Powered Cache, and set up the matching Apache or Nginx rule.
url: "https://poweredcache.com/docs/file-optimizer-rewrite-rules/"
updated: "2026-12-02"
category: Cache Rules
---

# File Optimizer Rewrite Rules

When you minify or combine CSS and JavaScript, Powered Cache serves the optimized files through its file optimizer. By default, their URLs point into the plugin folder, like `/wp-content/plugins/powered-cache/includes/file-optimizer.php??…`. With File Optimizer Rewrite Rules on, the same files load from a short URL on your site instead, like `https://example.com/_static/??…`. A server rewrite rule sends those requests to the file optimizer.

**Available in:** Powered Cache (free)
**Where to find it:** Powered Cache → File Optimization → Server configuration → **Write optimizer rewrite rules**
**Requires:** [Minify or Combine CSS](/docs/minify-and-combine-css/) or [Minify or Combine JavaScript](/docs/minify-and-combine-javascript/). On Apache and LiteSpeed, also [.htaccess Configuration](/docs/server-configuration/#htaccess). On Nginx, a rule you add by hand.

![](data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=)

## How it works

The setting changes two things. It changes the URLs that Powered Cache prints in your pages for optimized CSS and JavaScript files, and on Apache and LiteSpeed it adds a rewrite rule to your `.htaccess` file. The URL change happens whether or not the rule exists, so the server must have the rule, or the files return a *404 Not Found* error.

The setting is on by default when WordPress detects an Apache or LiteSpeed server, and off on other servers.

| Your setup | What Powered Cache does | What you do |
| --- | --- | --- |
| Apache or LiteSpeed, .htaccess Configuration on | Writes the rule into `.htaccess` when you save the settings | Nothing |
| Apache or LiteSpeed, .htaccess Configuration off | Changes the URLs but writes no rule | Turn .htaccess Configuration on, [add the rule by hand](#apache), or turn this setting off |
| Nginx | Changes the URLs but writes no rule | [Add the rule to your Nginx configuration](#nginx) before you turn the setting on |

## Apache and LiteSpeed

With [.htaccess Configuration](/docs/server-configuration/#htaccess) on, Powered Cache adds this rule inside its own block in the `.htaccess` file of your WordPress folder:

```
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^_static/.* wp-content/plugins/powered-cache/includes/file-optimizer.php [L]
</IfModule>
```

The path is the location of `file-optimizer.php` relative to your WordPress folder, so it differs if you moved `wp-content` or renamed the plugin folder. If you manage `.htaccess` yourself, add the same rule above the `# BEGIN WordPress` block and check that the path matches your site.

## Nginx

Nginx does not read `.htaccess`, and Powered Cache cannot change the Nginx configuration. Add a location like this to your site's `server` block, then reload Nginx:

```
location /_static/ {
    fastcgi_pass unix:/var/run/php/php-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/wp-content/plugins/powered-cache/includes/file-optimizer.php;
}
```

Use the same `fastcgi_pass` value and `fastcgi_params` include as the location that already handles PHP on your site. Turn the setting on only after the rule works. If you cannot edit the Nginx configuration, ask your host, or leave the setting off. Optimized files still work from the plugin URL. See [Server Configuration](/docs/server-configuration/#nginx).

## Turning the setting on or off

- **Off:** Powered Cache clears the page cache of the site when you save, so no cached page keeps pointing to `/_static/` URLs.
- **On:** pages that are already cached keep the old plugin URLs until they are cached again. Those URLs still work.

With [CDN Integration](/docs/cdn-integration/) on, Powered Cache replaces your site address in these URLs with your CDN hostname, so the files load from `https://cdn.example.com/_static/??…`.

## Check that it works

1. Open a page of your site in a private browser window and view the page source.
2. Search for `/_static/`. You should find the optimized CSS or JavaScript links.
3. Open one of those URLs. You should see CSS or JavaScript code, not an error page.

## Troubleshooting

### The site has no styles and /_static/ URLs return 404

The server has no rewrite rule for `/_static/`. Check these in order:

- On Apache or LiteSpeed, check that .htaccess Configuration is on, save the settings, and confirm that the rule appears in `.htaccess`. If the file is not writable, add the rule by hand.
- On Nginx, add the [location rule](#nginx) and reload Nginx.
- If you cannot add a rule, turn **Write optimizer rewrite rules** off and save. Powered Cache clears the page cache and goes back to the plugin URLs.

If the files load but the layout still looks wrong, the cause is the optimization itself, not the URL. See [Broken Layout After Optimization](/docs/broken-layout-after-optimization/).

## For developers

- `powered_cache_fo_relative_path` changes the path to `file-optimizer.php` used in the rewrite rule. Save the settings after adding the filter so the rule is written again.
- `powered_cache_fo_optimized_url` changes the final URL of each optimized file.

See the [hook reference](https://poweredcache.github.io/docs/).

## Related docs

- [Server Configuration](/docs/server-configuration/)
- [Minify and Combine CSS](/docs/minify-and-combine-css/)
- [Minify and Combine JavaScript](/docs/minify-and-combine-javascript/)
- [Broken Layout After Optimization](/docs/broken-layout-after-optimization/)
