Reputation: 3215
Every file is passed to "index.php", but every php file isn't properly redirected because of the fastcgi. Any workaround ?
location / {
if ($request_filename ~* "index.php") {
break;
}
rewrite ^/(.*)$ /index.php?page=$1 last;
break;
}
location ~* \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
Thanks
Upvotes: 2
Views: 873
Reputation: 7001
This is a working configuration I have:
location /media {
if (-f $request_filename) {
# filename exists, so serve it
break;
}
if (-d $request_filename) {
# directory exists, so service it
break;
}
rewrite ^/(.*)$ /media/index.php?$1;
}
It will redirect all requests that do not exist and would normally return a 404 error to the index.php
Upvotes: 2