Open flexchar opened 6 years ago
Check it
server {
listen 80;
server_name mydevsite.dev;
root /var/www/mydevsite/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_intercept_errors on;
}
}
@leotop thank you for sharing. It was a work for a client, that I have no more access to the given environment. Hence unable to test it.
Doesnt work for me, my nginx.conf
server {
listen 80;
server_name ndower.dev;
root /srv/http/agc/nanite;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_intercept_errors on;
}
}
my php
<?php
require_once('Nanite.php');
require_once('functions.php');
get('/', function(){
echo 'index';
});
get('/about', function(){
echo '<pre>'.print_r($_SERVER, true).'</pre>';
echo 'about page';
});
if (!Nanite::$routeProccessed) {
echo "404";
}
when goto ndower.dev/about, result 404
Hi, it does not work well with Nginx. Here is the working configuration, or else it does NOT see url and ALWAYS return 404.
The issue however is that any GET request parameters are invisible to PHP.
Using standard configuration will cause a redirection loop.