Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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.