nginx pathinfo配置

linux上布置好环境后,访问localhost正常,但是访问其他页面均报404错误,百度结果为pathinfo没有配置。试了很多个,最后还是用了我同事的配置代码才解决的。代码如下:

      location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
           if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?s=$1 last;
          }
        }
        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }
        location ~ \.php/ {
           if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
           fastcgi_pass 127.0.0.1:9000;
           include fastcgi_params;
           fastcgi_param SCRIPT_NAME     $1;
           fastcgi_param PATH_INFO       $2;
           fastcgi_param SCRIPT_FILENAME $document_root$1;
        }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

不同的环境配置的代码可能不同,网上的版本有几种,不过差别不是很大,主要的配置代码在 location ~ .php/,有的人适用,有的人不适用,可以多试下

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,384评论 19 139
  • 上一篇《WEB请求处理一:浏览器请求发起处理》,我们讲述了浏览器端请求发起过程,通过DNS域名解析服务器IP,并建...
    七寸知架构阅读 81,436评论 21 356
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,322评论 25 709
  • For as long as humans have romanced each other, otherd ha...
    Eudemonia_b8cf阅读 1,924评论 0 0
  • 一个人的时候丰富精神食粮,两个人的时候享受悠闲时光,一家人的时候品味幸福生活。 ** 请问,有何人不会向往面朝大海...
    hyTaurus阅读 1,865评论 0 3