因网站根据需求进行维护说明,需要把所有的访问都指向一个页面。
尝试方案:
location ~* \.(php|html|htm)$ {
index Index_weihu.html;
}
‘尝试一下的上述的方式是无法进行处理,依然可以访问静态网站下的所有的地址。
尝试方案2:
location / {
try_files '' /Index_weihu.html;
}
location = /Index_weihu.html {
index Index_weihu.html;
}
上述的方式是可以滴!
PS: try_files '' /Index_weihu.html; 中的是需要存在目录文件,否则可能会报错!
补充学习知识点:
nginx 中的try_files 主要是用于重定向。
网友评论