I want to add a version/timestamp query string to the end of my CSS and JS asset URLs. I have been using <?= css('assets/styles.min.css') ?> in the head tag but I can’t figure out if I can append a query string using that method.
So, for now I have switched to <link href="https://.../assets/styles.css?v=<?php echo time(); ?>" rel="stylesheet">. That works but, of course, means that I have to hard code the absolute URL.
(I have tried a couple of plugins but they seem to add the timestamp to the actual filename rather than adding a query string. And I couldn’t find anything in the Forum that was basic enough for me!)
Is there a way to add a query string whilst still using the css() method?
No, you’re right, I shouldn’t have used ‘time’. I want to add the timestamp of last file modification. I think I might need to return to one of the plugins but learn how to configure the .htaccess REWRITE COND to place the timestamp as a query string.
For example, the .htaccess condition supplied with the Cachebuster plugin generates the filename as…
but what I want to achieve is…
If you have a suggestion other than me learning more about .htaccess formatting, I’d be very grateful.