客戶端瀏覽器訪問替換html中的字符:javascript
location / { root /web/htdocs; random_index on; index index.html index.htm; subs_filter_types text/css text/plain application/x-javascript application/javascript; subs_filter http:// 'https://'; subs_filter abc.org 'xyz.net'; subs_filter caoss.com 'css.net';//第一個參數是要被替換的,第二個參數是替換後的 sub_filter_once off; //替換全部的,默認是on,替換第一個 }
改完保存下,使用命令檢查nginx語法是否正確:css
[root@cms-nginx /]# /App/nginx/sbin/nginx -t the configuration file /App/nginx//conf/nginx.conf syntax is ok configuration file /App/nginx//conf/nginx.conf test is successful
平滑重啓Nginx:html
[root@cms-nginx /]# /App/nginx/sbin/nginx -s reload