首页 > nginx伪静态的问题

nginx伪静态的问题

如何配置nginx,使得打开 www.x.cn/a 时,访问www.x.cn/a.html


server {
  index index.html index.php;
  location / {
    try_files $uri $uri/ $uri.html $uri.php?$query_string;
  }
  location ~ \.php$ {
    try_files $uri =404;
    # add fastcgi_pass line here, depending if you use socket or port
  }
}

核心是 try_files 指令的使用, 你可以参考NGINX的文档

【热门文章】
【热门文章】