Vanilla Forum http://vanillaforums.org/
location / {
try_files $uri $uri/ /index.php?p=$uri&$args;
}
WordPress http://wordpress.org
根目录
location / {
try_files $uri $uri/ /index.php?$args;
}
其他目录,例如:example.com/blog/
location /blog/ {
try_files $uri $uri/ /blog/index.php?$args;
}
遇到502 时自动转跳到维修页
error_page 502 = @fallback;
location @fallback {
rewrite ^(.*)$ /你的维修页.html break;
}
YOURLS (Your Own URL Shortener)http://yourls.org
location / {
try_files $uri $uri/ /yourls-loader.php;
}
重写 jQuery-x.x.x.min.js 到最新版(x = 单位数字)
location ~* jquery\-(\d|\.)*\.min\.js$ {
rewrite ^ http://example.com/assets/js/latest-jquery.min.js last;
alias /绝对路径/jquery-1.4.4.min.js;
# 绝对路径 - 例如:/www/my-website/assets/js/jquery-1.4.4.min.js
}
更新:
改用 alias
,省掉 redirect 的时间
可以参考 nginx 的官方维基[Link]
HTML5 Boilerplate 的时间戳
例如:
<!-- 旧的时间戳 -->
<link rel="stylesheet" href="css/anotherstyle.css?ver=2">
<!-- 新的时间戳 -->
<link rel="stylesheet" href="css/anotherstyle.2.css">
注:文件名保持不变,还是 anotherstyle.css
重写方法:
location ~* (.+)\.(\d+)\.(js|css|png|jpg|jpeg|gif)$ {
try_files $uri $1.$3;
}
更新 – HTML5 Boilerplate 官方语法 via
## 这个时间戳不适合配合 W3CTotalCache 这款插件一起使用。