我想实现清除缓存,为prescribed方式: http://html5boilerplate.com /文档/ cachebusting /
然而,当我添加以下到我的媒体文件夹中的.htaccess文件:
< IfModule mod_rewrite.c>
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^ ( d +)(JS | CSS | PNG | JPG | GIF)(+)。$ $ 1. $ 3 [L]
< / IfModule>
,然后我试图访问一个样式表的:/media/css/styles.1234.css阿帕奇抱怨有:
未找到
所请求的URL /media/css/styles.1234.css在此服务器上找到。
我可以在/media/css/styles.css访问styles.css的所以它的存在和它的作品。我也知道,htaccess的文件被处理,因为我们也禁止目录被浏览与选项-Indexes的媒体文件夹。下面是全部的htaccess文件:
选项-Indexes
设置AllowOverride所有
< IfModule mod_rewrite.c>
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^ ( d +)(JS | CSS | PNG | JPG | GIF)(+)。$ $ 1. $ 3 [L]
< / IfModule>
此外mod_rewrite的已被证实要加载使用此命令:a2enmod重写。不知道我在做什么错了?
解决方案下面是解决我的问题......即使加载mod_rewrite的,它需要在设定为。所以,我只是交锋RewriteEngine叙述上......造成htaccess文件:
选项-Indexes
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^ ( d +)(JS | CSS | PNG | JPG | GIF)(+)。$ $ 1. $ 3 [L]
< / IfModule>
I'm trying to implement cache busting, as prescribed by: http://html5boilerplate.com/docs/cachebusting/
However when I add the following to the .htaccess file in my media folder:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).(d+).(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>
and then I try to access a style sheet at: "/media/css/styles.1234.css", Apache complains with:
Not Found
The requested URL /media/css/styles.1234.css was not found on this server.
I can access styles.css at "/media/css/styles.css" so it's there and it works. I also know that the htaccess file gets processed because we also disallow directories from being browsed in the media folder with "Options -Indexes". Here is the htaccess file in its entirety:
Options -Indexes
AllowOverride All
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).(d+).(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>
Also mod_rewrite has been confirmed to be loaded with this command: 'a2enmod rewrite'. Not sure what I'm doing wrong...
解决方案Here is the solution to my problem... Even though mod_rewrite was loaded, it needed to be set to on. So I just aded "RewriteEngine On"... resulting htaccess file:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).(d+).(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>