Reputation: 23
I got a filename like jquery.form.min.3.51.0-2014.06.20.js
and want to change the following my rewrite rule to remove the dots, the dash and the digits.
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>
The rewrite rule does it jobs on filenames like scripts.min.4.4.2.js
which is forwarded to scripts.min.js
. But for the filename at the top, with the dash inside between the digits, the rule won't work.
My regex knowledge is too limited for this case. Could anybody give me a hint please?
Upvotes: 1
Views: 254
Reputation: 80639
Try the following:
RewriteRule ^(\D+)[\d.-]+(js|css|png|jpg|gif)$ $1$2 [L]
Upvotes: 1
Reputation: 18671
You can use:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.[\d-]+\.(js|css|png|jpg|gif)$ $1.$2 [L]
</IfModule>
Upvotes: 1