0

SO I am trying to setup a RewriteRule on my server for caching static objects. the files are in this naming scheme /docroot/css/stylesheet.min.css and I have them printed in the code like /docroot/css/stylesheet.min.123438348.css (the number is example it comes from a get modified function). Note docroot is an example directory

how can I have the server ignore the numbers and redirect to the stylesheet.min.css I need to do this for every css and js files (/js and /css) as well as one specific spritemap image

my current attempt

RewriteRule ^/(docroot)/(js|css)/(.+).(min).(.+).(js|css)$ /$1/$2/$3.$4.$6
RewriteRule ^(/docroot/images/spritemap).([0-9]+).(png)$ $1.$3

Update: Now I have the setup like this

<Location />
RewriteEngine on
Options FollowSymLinks
RewriteRule ^(.+)\.(min)\.([0-9]+)\.(js|css)$ $1.$2.$4 [L]
</Location>

This is rewriting localhost/docroot/css/stylesheet.min.12343242.css to /var/www/html/docroot/trunk/docroot/css/stylesheet.min.css

so it is getting the right file how do I get apache to take off the beginning of the that the /var/www/html/docroot/trunk/

<Location />
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.+)\.(min)\.([0-9]+)\.(js|css)$ $1.$2.$4 [PT]
</Location>

Ok Now instead of

/var/www/html/docroot/trunk/docroot/css/stylesheet.min.css

I am getting a url that looks like this

/docroot/trunk/docroot/css/stylesheet.min.css

I Removed the RewriteBase command so I still need to remove the beginning /docroot/trunk

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by mikeandike22
0

RewriteRule ^.+/(js|css)(.+)\.(min)\.([0-9]+)\.(js|css)$ /docroot/$1$2.$3.$5


This Works

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.