nginx关键字替换模块sub_filter替换方法

Nginx自带的sub_filter模块可以将自定的关键字替换为指定的字符,比如将Admin字符替换为mydns字符,方法如下 location /{ root   /home/wwwroot/mydns/; random_index on; index  index.html in...

Nginx自带的sub_filter模块可以将自定的关键字替换为指定的字符,比如将Admin字符替换为mydns字符,方法如下

location / {

root   /home/wwwroot/mydns/;

random_index on;

index  index.html index.htm;

sub_filter '<h1>Admin' '<h1>mydns';  //第一个参数是要被替换的,第二个参数是替换后的

sub_filter_once off;   //替换所有的,默认是on,替换第一个

}

修改后保存,使用命令检查nginx语法是否正确(路径更换为自己的路径)

nginx -tc /etc/nginx/nginx.conf

平滑重启nginx

nginx -s reload -c /etc/nginx/nginx.conf

  • 发表于 2020-11-25 15:49
  • 阅读 ( 2242 )
  • 分类:服务器

0 条评论

请先 登录 后评论
东北大表哥
东北大表哥

自由职业

161 篇文章

作家榜 »

  1. 东北大表哥 161 文章
  2. 小鹄 1 文章
  3. 阿天 0 文章
  4. 新百胜在线 0 文章
  5. 刘明明 0 文章
  6. 个的德3 0 文章
  7. 铂天先生 0 文章
  8. 王达 0 文章