• nginx服务器去掉url中的index.php 和 配置path_info


    隐藏index.php

     server {
            listen          80;
            server_name     yourdomain.com;
            root            /home/yourdomain/www/;
            index           index.html index.htm index.php;
    
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php$1 last;
            }
    
            location ~ .*.php(/.*)*$ {
                include fastcgi.conf;
                fastcgi_pass  127.0.0.1:9000;
            }
    
            access_log logs/yourdomain.log combined;
        }
    

    配置path_info  

    server {
    	listen       80;
    	server_name  test.local;
    
    	location / {
    		root   /www/test;
    		index  index.html index.htm index.php;
                    rewrite ^(.*)$ /index.php$1 last;
    	}
    	location ~*  .php {
    		fastcgi_index	index.php;
    		fastcgi_split_path_info ^(.+.php)(.*)$;
    		fastcgi_param	SCRIPT_FILENAME	$document_root$fastcgi_script_name;
    		fastcgi_param	PATH_INFO		$fastcgi_path_info;
    		fastcgi_param	PATH_TRANSLATED	$document_root$fastcgi_path_info;
    		fastcgi_pass    unix:/tmp/php-fpm.sock;
    		include	fastcgi_params;
        }
    }
    

      

  • 相关阅读:
    nginx原理及常用配置
    课程作业03-1
    Java动手动脑02
    Java课程作业02
    java课堂测试2
    Java验证码程序
    课程作业02-2
    课程作业02-1
    课程作业01
    《大道至简》第一章伪代码
  • 原文地址:https://www.cnblogs.com/thrillerz/p/4722878.html
Copyright © 2020-2023  润新知