Forum Moderators: phranque

Message Too Old, No Replies

Remove timstamp from css js files

         

chitech

11:15 am on Jan 10, 2014 (gmt 0)

10+ Year Member



Hi

When I get these requests:

http(s)://mydomain/path1/file1._20140101.css
http(s)://mydomain/path1/path2/file2-2.50._20140202.js

it should proxy to:

"http://backend/path1/file1.css"
"http://backend/path1/path2/file2-2.50.js"

I would like to remove this separator: ._[0-9]+ just before the file extension.

Something like this:
RewriteCond %{REQUEST_URI} \._[0-9]+\.(js|css)$
RewriteRule /(.*)\._([^.]*)$ /$1.$2 [P]

lucy24

8:41 pm on Jan 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oh, ###. Oh, ###. Literal periods in the filename? Why, for ### sake? Are they so deeply imbedded in your programming that it would be more trouble than it's worth to change them?

Does the lowline always come immediately after a . period?

Do you ever have lowlines in directory names? If not, it looks like

^/([^_]+)\._\d+\.(js|css)
going to
/$1.$2

but your suggested rule doesn't match the prose, so I'm not sure what the intention really is.

:: detour to Apache docs to confirm that [P] flag implies [L] ::

g1smd

8:58 pm on Jan 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In order to "remove the separator" you'll need to amend the PHP script that generates the links that appear in the HTML source code of the pages sent to the browser from the server.

The second step is to amend the pattern of the rewrite so that it matches the new requests.