首页>>帮助中心>>vps云服务器Nginx实现页面的动静分离

vps云服务器Nginx实现页面的动静分离

2023/11/21 259次
 Nginx实现页面的动静分离


 Nginx可以使用localhost匹配用户的请求,根据正则表达式判断用户访问的是静态页面还是

 动态页面。

 样例配置如下:

 #cat /usr/local/nginx/conf/nginx.conf

 ……

 server{

 listen80;

 server_namelocalhost;

 location/{

 //识别静态页面(除了 PHP外的其他所有页面)

 roothtml;

 indexindex.html;

 }

 location~*\.php${

 //识别动态页面

 roothtml;

 fastcgi_pass127.0.0.1:9000;

 include fastcgi.conf;

 }

 }