当前位置: 动力学知识库 > 问答 > 编程问答 >

.htaccess - htaccess How to add a versioning number to css and js files

问题描述:

I need a simple htaccess rule to add a string to all css and js files.

everytime we update the software we need to make sure that people load the new js and css files and not use the cached ones...

I found some code where they strip out the version number.

 RewriteRule ^(.*)\.[0-9]{10}\.(css|js)$ $1.$2 [L] # Strip out the version number

but I would actually need the opposite.

at the moment a css file is like that in the page

 <link rel="stylesheet" href="css/forms.css" type="text/css">

I would like to accheive

 <link rel="stylesheet" href="css/forms.css?v=118" type="text/css">

same for JS

Your help is much appreciated

Thanks

分享给朋友:
您可能感兴趣的文章:
随机阅读: