让Nginx支持SCRIPT_URL
由于访问增加,将服务器由apache转换到了nginx。
由于框架底层里用到了SCRIPT_URL,需要配置nginx支持这个参数。
特记录配置:
server { listen 80; server_name test.com; root /data/www; location / { index index.php; } if ( $fastcgi_script_name ~ \..*\/.*php ) { return 403; } # if the request file name contains one of the below extensions, # serve it directly if ($request_filename ~* \.(js|ico|gif|jpg|png|css|xml|php|txt)$) { break; } # otherwise, /index.php handles the request rewrite ^(.*)$ /index.php$1 last; location ~ ^(?P.+\.php)(?P .*)$ { include fastcgi_params; fastcgi_param PATH_INFO $PATH_INFO; fastcgi_param DOCUMENT_ROOT /data/www; fastcgi_param PATH_TRANSLATED $document_root$PATH_INFO; fastcgi_param SCRIPT_FILENAME $document_root$SCRIPT_FILENAME; fastcgi_index index.php; fastcgi_param RUN_MODE production; # Attention! Both PHP_SELF and SCRIPT_NAME must contain the same value, # but they don't! fastcgi_param PHP_SELF $uri; fastcgi_param SCRIPT_NAME $uri; # set SCRIPT_URL/SCRIPT_URI for compatibility fastcgi_param SCRIPT_URL $PATH_INFO; fastcgi_param SCRIPT_URI $scheme://$http_host$PATH_INFO; fastcgi_param PHP_VALUE "include_path=$document_root:$document_root/include"; try_files $SCRIPT_FILENAME =404; fastcgi_pass unix:/tmp/php-fcgi-faq.sock; } }
亲啥时候写的