I wrote a utility to handle the versioning of my CSS and JS files for caching purposes, however, I'm struggling to get the RewriteRule setup correctly to load the original file.
The way the versioning utility writes the new URL is as below:
Local
<script src="20110125/contact.js" type="text/javascript"></script>
Global
<script src="../Scripts/js/20110125/core.js开发者_开发知识库" type="text/javascript"></script>
My RewriteRules strip out the timestamp and load just the path and filename. They are as follows:
#rewrite core js
RewriteRule ^(\/Scripts\/[a-z]*\/)[0-9]*\/(.*) $1$2 [NC]
#rewrite directory level js
RewriteRule .+\/(.+\.js) $1 [NC]
However, when I make a page request I get a 404 on the pages. Any help is appreciated.
You have a rather bizarre path to your JS files; I'd recommend just using /js
or /javascript
, and don't use capital letters in file or path names in a URL. What are you trying to do with your second RewriteRule?
# /js/123456/jquery.js to /js/jquery.js
RewriteRule ^/js/[0-9]+/(.+).js$ /js/$1.js [L]
精彩评论