MarcF
MarcF

Reputation: 3299

mod_rewrite remove url component

How would I specify a .htaccess condition that rewrites the following url:

http://test.com/files/js/version345/user.js

to

http://test.com/files/js/user.js

Here the version number is incremented, i.e. version346, version347 etc.

I'd like to do this as a more reliable way of forcing browsers to get updated javascript files when they ignore query parameters and MAX-AGE http headers.

Upvotes: 1

Views: 23

Answers (1)

anubhava
anubhava

Reputation: 785256

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^(files/js)/version\d+/(.+\.js)$ /$1/$2 [L,NC]

Upvotes: 1

Related Questions