HTML5 Boilerplate .htaccess cache busting not working with WordPress

The .htaccess cache settings for HTML5 Boilerplate (http://html5boilerplate.com/) are awesome, but I’m running into an issue with the cache busting settings for JS and CSS versioning.

<IfModule mod_rewrite.c>
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+).(d+).(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>

I can’t seem to get this to work with the WordPress rewrite settings already present in the .htaccess file.

Read More
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>

At best, the rewrite on my JS files never happens. At worst, it breaks the site.

Anyone had any luck getting this to work with WordPress?

Related posts

Leave a Reply

3 comments

  1. Can you make some php.ini settings embeded into your .htaccess and then test website for changes, Just to test even if you .htaccess file working or not?

    In most cases I have experienced that, there are a few hidden files which CentOS 5.5 based systems does not show (don’t know if its already known bug). But if you create a new file with same name .htaccess you will see a few different lines than your original one.

    Simply means both are two different files. So just try to check which one is working with your website. Moreover for compressing JS and CSS files, I have written a quite detailed tutorial here
    http://www.codeandcommand.com/web-based/how-to-optimize-joomla-3-x-pagespeed.html

    • Make sure your cache-busting URLs actually match the rewrite pattern (script.0.js)
    • Put cache-busting rewrite rules before WordPress’s
    • If you can access the server config and read the logs, set RewriteLog 2 (or higher) and then look at the rewrite logs. They’re hard to follow but they can give you some clues.
    • “At worst, it breaks the site.” If that means you’re getting 500 server error, check your server logs — it will tell you if there’s a rewrite loop.

    Change WordPress’s rule to

    RewriteRule ^[w/-]+$ /index.php [L]
    

    and see if that helps.

    At best, the rewrite on my JS files never happens.

    Are you seeing WordPress’s “not found” response or Apache’s?

    At worst, it breaks the site.

    Apache server error or WordPress error?