0

I am using Filename-based cache busting, to make sure every time I make a change to a file resource revving happens (Steve Sounders Post).

For this matter I am using the following .htaccess file directive (HTML5 Boilerplate):

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

In other words, all requests to "css/style-min.123.css" go to "css/style.css"

This is what I have in the page.xml file:

<action method="addCss"><stylesheet>css/styles-min.12.css</stylesheet></action>

The file "styles-min.css" is under my theme css folder (/skin/frontend/default/myTheme/css/styles-min.css)

However when I load the front page I get a not found error because magento searches for that file on the base theme css folder:

The requested URL /skin/frontend/base/default/css/styles-min.css was not found on this server.

Of course, if I copy styles-min.css to that folder, the site works fine (which means the .htaccess directive is good)

Can I make Magento search for that file under my theme's css folder even though it does not exist as a real file?

Hope I made myself clear enough.

Thanks!

  • is your theme set-up in the admin section? – David Manners May 29 '14 at 16:52
1

I'm afraid your approach won't work unless you put all your files in the base/default folder. And here is why.

When building the <head> block magento parses the addCss method, but does not make a HTTP request for the file, so your .htaccess rule has no power here.
See how the method _prepareStaticAndSkinElements in the head block looks like.
The main idea is that Magento looks for the resource (on the disk) in the current theme, if it's not there falls back to the default theme you set and finally to base/default. In this last fallback it doesn't check for the existence of the file. It just assumes it's there.

What you can do is (like I said above) put all your resources in base/default (not really best practice), or you can create symlinks on the disc from skin/fronend/{package}/{theme}/css/styles-min.12.css to skin/fronend/{package}/{theme}/css/styles-min.css

Or you can use this extension, that let's you add ?v=XX at the end of the css/js files. The v is manageable from the backend.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.