环境说明:

我试用的lnmp安装包安装的nginx,nginx版本是1.14.1

  1. server {
  2. listen ;
  3. server_name www.baidu.com;
  4. #access_log /data/wwwlogs/access_nginx.log combined;
  5. root /data/wwwroot/wechatadmin/backend/web;
  6. #root /data/wwwroot/game;
  7. index index.html index.htm index.php;
  8. #error_page /.html;
  9. #error_page /.html;
  10. location /nginx_status {
  11. stub_status on;
  12. access_log off;
  13. allow 127.0.0.1;
  14. deny all;
  15. }
  16. location ~ [^/]\.php(/|$) {
  17. #fastcgi_pass remote_php_ip:;
  18. fastcgi_pass unix:/dev/shm/php-cgi.sock;
  19. fastcgi_index index.php;
  20. include fastcgi.conf;
  21. }
  22. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  23. expires 30d;
  24. access_log off;
  25. }
  26. location ~ .*\.(js|css)?$ {
  27. expires 7d;
  28. access_log off;
  29. }
  30. location ~ /\.ht {
  31. deny all;
  32. }
  33.  
  34. location / {
  35. try_files $uri $uri/ /index.php?$query_string;
  36. }
  37.  
  38. if (!-d $request_filename)
  39. {
  40. rewrite ^/(.+)/$ /$ permanent;
  41. }
  42.  
  43. # 去除index action
  44. if ($request_uri ~* index/?$)
  45. {
  46. rewrite ^/(.*)/index/?$ /$ permanent;
  47. }
  48.  
  49. # 根据laravel规则进行url重写
  50. if (!-e $request_filename)
  51. {
  52. rewrite ^/(.*)$ /index.php?/$ last;
  53. break;
  54. }
  55. #error_page /50x.html;
  56. location = /50x.html {
  57. root html;
  58. }
  59. }

nginx下配置Yii2 rewrite、pathinfo等的更多相关文章

  1. nginx下配置laravel+rewrite重写

    server { listen ; server_name ha.d51v.cn; #access_log /data/wwwlogs/access_nginx.log combined; root ...

  2. Nginx下配置ThinkPHP的URL Rewrite模式和pathinfo模式支持

    前面有关于lnmp环境的搭建,在此就不在赘述.下面就简述thinkPHP如何在nginx下开启url_rewrite和pathinfo模式支持 主要有两个步骤: 一.更改php.ini将;cgi.fi ...

  3. 如何在Nginx下配置PHP程序环境

    1.nginx与PHP的关系 首先来看nginx与php的关系, FastCGI的关系(而不是像apache那样安装成nginx的模块) FastCGI的意思是, 快速的通用网关接口:CGI Comm ...

  4. Nginx下WordPress的Rewrite

    最近接触WP Super Cache,该插件要求固定链接必须是重写的,故用到Rewrite. 我的是这样配置的: /usr/local/nginx/conf/rewrite/wordpress.con ...

  5. codeigniter(ci)在nginx下返回404的处理方法即codeigniter在nginx下配置方法

    codeigniter(ci)在nginx下返回404的处理方法即codeigniter在nginx下配置方法 进入nginx的配置文件 加上一句(本来就有这句,只需要修改一下就行了) locatio ...

  6. NGINX下配置404错误页面的方法分享

    NGINX下配置自定义的404页面是可行的,而且很简单,只需如下几步,需要的朋友可以参考下   1. 创建自己的404.html页面 2.更改nginx.conf在http定义区域加入: fastcg ...

  7. Ubuntu Nginx下配置网站ssl实现https访问

    最近在看  HTTP权威指南   看到介绍了HTTPS的ssl,自己就动手测试了下,将步骤记录下 HTTPS简介 什么是HTTPS?百科是这样解释的.HTTPS(全称:Hyper Text Trans ...

  8. tpadmin的坑收集 nginx下配置tp5失败

    如下: 1.ADMIN模块如要关联查询,model的函数名一定不要有“_”下划线,否则找不到 /common/model/**.php 如果把函数名file写成“**_file”,调用时,$vo.** ...

  9. nginx下配置多个web服务

    参考 nginx配置详解  nginx反向代理与负载均衡详解 一.nginx简介: Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能 ...

随机推荐

  1. dos for循环

    in (phone.txt) do ( 127.0.0.1 > tmp_file ) ) do ( 127.0.0.1 > tmp_file )

  2. 20-----定位 (Position)

    定位 定位有三种: 1.相对定位 2.绝对定位 3.固定定位 这三种定位,每一种都暗藏玄机,所以我们要一一单讲. 相对定位 相对定位:相对于自己原来的位置定位 现象和使用: 1.如果对当前元素仅仅设置 ...

  3. 【ACM】吝啬的国度 - DFS (图)

    吝啬的国度 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 在一个吝啬的国度里有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来.现在,Tom在第S号城市, ...

  4. python3——“->”的含义

    ->:标记返回函数注释,信息作为.__annotations__属性提供,__annotations__属性是字典.键return是用于在箭头后检索值的键.但是在Python中3.5,PEP 4 ...

  5. int,long,long long的数据范围

    unsigned   int   0-4294967295   int   2147483648-2147483647 unsigned long 0-4294967295long   2147483 ...

  6. 使用Java生成带有下划线字体的文字

    HashMap<TextAttribute, Object> hm = new HashMap<TextAttribute, Object>(); hm.put(TextAtt ...

  7. 八个cmd 命令

    一,ping 它是用来检查网络是否通畅或者网络连接速度的命令.作为一个生活在网络上的管理员或者黑客来说,ping命令是第一个必须掌握的DOS命令,它所利用的原理是这样的:网络上的机器都有唯一确定的IP ...

  8. npm安装使用淘宝代理的方法(设置registry参数)

    公司防火墙问题导致 npm下载失败,安装使用cnpm不知道什么原因抽筋, 还有一个简单的办法,就是npm安装模块时,设置代理: npm install -g vue-cli --registry=ht ...

  9. html 02-认识html

    1. HTML 初识 HTML 指的是超文本标记语言 (Hyper Text Markup Language)是用来描述网页的一种语言. HTML 不是一种编程语言,而是一种标记语言 (markup ...

  10. logback的configuration

    logback的<configuration>只有三个属性: 1.scan[boolean]:当scan被设置为true时,当配置文件发生改变,将会被重新加载.默认值为true. 2.sc ...