• 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;

  • 相关阅读:
    linux tcp中time_wait
    linux查看系统信息
    运行程序出错无法找到库文件
    安装keepalived
    python 深拷贝与浅拷贝
    python import eventlet包时提示ImportError: cannot import name eventlet
    [原创] 用两个queue实现stack的功能
    [原创] 用两个stack实现queue的功能
    [原创] 编写函数,实现对链表元素的排序与分类
    python 装饰器
  • 原文地址:https://www.cnblogs.com/xuxiaoman/p/14619571.html
Copyright © 2020-2023  润新知