Skip to content

Instantly share code, notes, and snippets.

@dave1010
Created May 24, 2011 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave1010/988704 to your computer and use it in GitHub Desktop.
Save dave1010/988704 to your computer and use it in GitHub Desktop.
mod_rewrite filename-123.css to filename.css
# only for files / directories that don't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# remove "-" and any digits preceding a file extension
RewriteRule ^(.*)\-[0-9]+(\.[a-z]+)$ $1$2 [L]
# works for CSS, JS, images, etc.
# means you can set far-future expires headers (so browsers cache files lots)
# whilst being able to easily invalidate the cache, just by changing the version number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment