Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any universal rule to rewrite versions?

/css/main.123456.css rewrite to /css/main.css

/css/styles.123456.css rewrite to /css/styles.css

/js/application.123456.js rewrite to /js/application.js

How should I modify my .htaccess file to add universal versioning for css/js files?

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
share|improve this question
RewriteRule ^(css|js)/(main|styles|application)\.[0-9]+(\.css|\.js)$ /$1/$2$3 [L]

You would actually be better NOT altering the WP .htaccess rules and just put your code before it.

That way, Wordpress can make changes without it removing yours

Eg.

RewriteEngine On
RewriteBase / 
RewriteRule ^(css|js)/(main|styles|application)\.[0-9]+(\.css|\.js)$ /$1/$2$3 [L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.