nginx配置指定路径去掉php后缀配置

location ^~ /api/
	{
	    if (!-f $request_filename){
	    	rewrite "^/api/(.*)$" /api/$1.php;
	    	#rewrite "^/api/(.*)$" http://www.baidu.com?$1;
		break;
	   }
	   try_files $uri =404;
	   fastcgi_pass  unix:/tmp/php-cgi.sock;
	   fastcgi_index index.php;
	   include fastcgi.conf;
	}


访问根目录下面api时,去掉api下面php后缀情况



你可能感兴趣的:(linux,PHP)