美文网首页
nginx pathinfo配置

nginx pathinfo配置

作者: 衡阿大 | 来源:发表于2017-04-24 10:45 被阅读0次

    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/,有的人适用,有的人不适用,可以多试下

    相关文章

      网友评论

          本文标题:nginx pathinfo配置

          本文链接:https://www.haomeiwen.com/subject/bgvuzttx.html