nginx伪静态,终于知道是什么意思了。

就是在宝塔每一个网站,均可以配置是否开启伪静态。

网上也有很多的代码,今天解决了thinkcmf配置nginx伪静态,

 代码如下:

location / {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
#rewrite ^/(.*)$ /index.php?s=$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
rewrite ^/public/(.*)$ /public/index.php?s=$1;
}
error_page 405 =200 http://$host$request_uri;
}

location /api/ {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
#rewrite ^/(.*)$ /index.php?s=$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
rewrite ^/api/(.*)$ /api/index.php?s=$1;
}
error_page 405 =200 http://$host$request_uri;
}

location /apiv2/ {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
#rewrite ^/(.*)$ /index.php?s=$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
rewrite ^/apiv2/(.*)$ /apiv2/index.php?s=$1;
}
error_page 405 =200 http://$host$request_uri;
}

因为有api 和 apiv2,两个api目录均可以被访问,所以配置了多种写法。另外,访问的时候依然报错,这是因为nginx拦截了、

加上这一句,就不会再报错了。

error_page 405 =200 http://$host$request_uri;

原文地址:https://www.cnblogs.com/xuxiaoman/p/14619571.html