Support » Plugin: W3 Total Cache » [Plugin: W3 Total Cache] Rewritten CSS URL doesn't match uploaded CSS URL

  • Resolved Mikzi


    When upgrading to the latest version of WP (3.0.1) the rewritten CSS URL no longer matches the uploaded CSS URL. This issue appeared on three separate WordPress installations that I’m running after the upgrade.

    The sites are using the latest plugin version of W3 Total Cache. The settings are the default ones with CDN (Cloudfront) configured. “Rewrite URL structure” is enabled under Minify settings since disabling this setting seems to prevent uploading of minified files to my CDN in this version of the plugin (“Host minified CSS and JS files” becomes grayed out).

    Basically, the CSS URL “”
    Is rewritten as “”.

    However, the Minified CSS file is uploaded to the following Amazon CloudFront directory:
    mydir/wp-content/w3tc/min/f1b32b/default.include.2648424108.css.gzip OK
    mydir/wp-content/w3tc/min/f1b32b/default.include.2648424108.css OK

    The “mydir” part is the problem (or lack of “mydir” in the rewrite). This is the name of the physical directory WP is installed at (different for each site).

    I’d be very grateful if someone could shed some light into this mystery.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Frederick Townes


    Is your site in network mode?

    No. Each site has a separate WP install and database, although they’re located on the same web host.

    In the Minify settings the CSS file is specified as “wp-content/themes/mytheme/style.css”. The URI verifies correctly. Interestingly, specifying the URI as “mydir/wp-content/themes/mytheme/style.css” produces the exact same result. The URI verifies, the uploaded file gets prefixed with “mydir” while the rewritten CSS URL does not.

    It seems the issue is not specific to minified CSS files. Theme files and WP-includes are also uploaded to the subdirectory mydir on Cloudfront, while their URL is rewritten without the mydir on the web pages.

    To confirm, this problem appeared when switching from to I did some analyses of the code and believe the source of this issue to be the w3_get_document_root() function in define.php which has received some additional calls from /lib/W3/Plugin/Cdn.php in the new version.

    For example, in the previous version of Cdn.php we had that the minify path was a constant “W3TC_CONTENT_MINIFY_DIR_NAME” defined as “wp-content/w3tc/min”. In the new version (line 1385) this path becomes the W3TC_CACHE_FILE_MINIFY_DIR subtracted from w3_get_document_root().

    In my case the doc root /myhome/public_html is removed from the constant /myhome/public_html/mydir/wp-content/w3tc/min, leaving the path as mydir/wp-content/w3tc/min instead of the desired /wp-content/w3tc/min.

    I believe w3_get_document_root() should have returned “/myhome/public_html/mydir” and not “/myhome/public_html”.

    Plugin Author Frederick Townes


    Can you submit a bug submission form from the support tab of the plugin?


    Plugin Author Frederick Townes



    Thanks for the help, Frederick.

    The problem has been solved so I’m closing this thread. It had to do with my custom .htaccess rules and the fact that my WP SiteUrl was incorrect.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: W3 Total Cache] Rewritten CSS URL doesn't match uploaded CSS URL’ is closed to new replies.