Welcome! Log In Create A New Profile

Advanced

Rewrite or alias for md5-file cache buster system (desperate)

Posted by Fleshgrinder 
Rewrite or alias for md5-file cache buster system (desperate)
November 04, 2011 11:31AM
Hi guys, I need your help. I'm desperately trying but fail with every try.

In PHP I have the following:

<?php

echo '<link rel="stylesheet" href="/style-'. md5_file(IP .'style.css') .'.css"/>';

echo '<script href="/script-'. md5_file(IP .'script.js') .'.js"></script>';

?>

If any of you isn't familiar with this, it outputs something like /style-bb2a053b6748240451d2e2952d284d52.css

Okay, so now I want to map this easily to another location on my server with nginx and this part just won't do as I want. I tried endless things I found here in the forum and elsewhere, but nothing works. Any help is much appreciated.

## Cache buster for style and script.
location ^~ /(style|script)-(.*)\.(css|js)$ {
rewrite /sites/all/themes/mytheme/$1.$3 last;
}

As I said, I tried different variations of this rewrite, I also tried alias instead of rewrite ... nothing works. ;(
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready