Nginx的rewrite
rewrite regex replacement flag;
rewrite ^/images/(.*\.jpg)$ /imgs/$1 所有的圖片跳轉到/imgs/$1
break;(結束位)
rewrite ^/shop/(.*\html)$ /tuangou/$1 break;
rewrite ^/shop/(.*\.php)$ http://www.baidu.com/$1 [redirect | permanent];
last - 基本上都用這個Flag(多級跳轉)
break - 中止Rewirte,不在繼續匹配
redirect - 返回臨時重定向的HTTP狀態302
permanent - 返回永久重定向的HTTP狀態
^(.*)$ //所有的請求
301
rewrite的confition
語法:if (condition) {..}
應用環境:server,location
upsteam name{ //nginx負載均衡
wrr; //加權算法
server //外部服務器 weight=2 max_fails=1 fail_timeout=1s;
server //外部服務器 weight=1 [down | backup];
}//單配置到http段
lcation / {
proxy_pass http://name; //跳轉到http://name
}
error_page 404 /404.html;
location = /404.html {
root /web/404;
}
alias /web 把"/" 別名成/web