1
Nginx應將/assets/css/main.1448958665.css
重寫爲/assets/css/main.css
。但試圖獲得該文件,它返回一個404
。Nginx重寫不起作用(Kirby CMS Cachebuster)
這是我的網站Nginx的配置:
server {
listen 80 default_server;
server_name example.com;
root /var/www/example.com;
index index.php index.html index.htm;
client_max_body_size 10M;
rewrite ^/(content|site|kirby)$ /error last;
rewrite ^/content/(.*).(txt|md|mdown)$ /error last;
rewrite ^/(site|kirby)/(.*)$ /error last;
location /assets {
if (!-e $request_filename) {
rewrite ^/(.+)\.(\d+)\.(js|css)$ /$1.$3 break;
}
}
location/{
try_files $uri $uri/ /index.php?$uri&$args;
}
location /panel {
try_files $uri $uri/ /panel/index.php?$uri&$args;
}
location ~ (?:^|/)\. {
deny all;
}
location ~ (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
deny all;
}
location ~* \.(svg|js|css|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot)$ {
expires 1y;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
}
}
我使用柯比CMS與緩存無效插件如果這樣做的幫助。
太好了,謝謝!認爲順序很重要,而不是定義規則的方式。現在工作! :) – roka