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

  

posted @ 2015-08-12 01:11  thrillerz  阅读(907)  评论(0编辑  收藏  举报