Bill H
Bill H

Reputation: 2069

Is there a better way to write this .htaccess directive?

I want all css, javascript, and image file requests, that are named like this "filename.12345.css" to be re-routed to "filename.css".

The ".12345" part will always be numbers and the length can be anywhere from 11 - 15 characters.

This directive seems to work OK but I want to make sure there is no error in my logic.

RewriteRule ^(.+)\.(.+)\.(js|css|jpg|gif|png)$ $1.$3

Any help would be greatly

Upvotes: 0

Views: 34

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798566

Extra periods can interfere.

RewriteRule ^(.+)\.([^.]+)\.(js|css|jpg|gif|png)$ $1.$3

or

RewriteRule ^(.+)\.(\d+)\.(js|css|jpg|gif|png)$ $1.$3

Upvotes: 1

Related Questions