Answer the question
In order to leave comments, you need to log in
Nginx: How to make rewrite and fastcgi friends?
Hello friends.
Tell me how to make rewrite and fastcgi friends? A bunch of nginx and php-fpm is running on the server.
The configuration is the following:
server
{
listen 80 default_server;
server_name example.com;
root /home/sites/example.com/;
access_log /var/log/nginx/example.com.bots.log advanced flush=1m buffer=32k if=$isBot;
access_log /var/log/nginx/example.com.access.log advanced flush=5m buffer=32k if=$isHuman;
error_log /var/log/nginx/example.com.errors.log warn;
location @php
{
include bootstrap/modules/php.conf;
}
location /
{
try_files $uri $uri/ /index.php?$query_string;
}
location /application
{
deny all;
}
location /errors/
{
alias /home/sites/example.com/application/views/errors/;
allow all;
}
error_page 403 /errors/403.html;
error_page 404 /errors/404.html;
error_page 500 /errors/500.html;
include bootstrap/modules/gzip.conf;
include bootstrap/locations/system.conf;
include bootstrap/locations/static.conf;
include bootstrap/locations/errors.conf;
include bootstrap/locations/php.conf;
}
include fastcgi_params;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_next_upstream error timeout;
fastcgi_keep_conn on;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $final_path_info $fastcgi_path_info;
set $final_script_name $fastcgi_script_name;
try_files $fastcgi_script_name = 404;
#fastcgi_param PATH_INFO $final_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$final_script_name;
fastcgi_param SCRIPT_NAME $final_script_name;
fastcgi_param REQUEST_URI $request_uri;
location ~ ^.+\.php
{
try_files false @php;
}
rewrite ^/stubs/api\.php(.*)$ /api/old$1 last;
include fastcgi_params;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_next_upstream error timeout;
fastcgi_keep_conn on;
set $final_path_info "";
set $final_script_name $uri;
if ($uri ~ "^(.+?\.php)(/.*)$")
{
set $final_path_info $2;
set $final_script_name $1;
}
try_files $fastcgi_script_name = 404;
#fastcgi_param PATH_INFO $final_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$final_script_name;
fastcgi_param SCRIPT_NAME $final_script_name;
fastcgi_param REQUEST_URI $request_uri;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question