PHP-FPM and Nginx rewrite download

I have a Nginx HTTP server with PHP-FPM, and almost everything works fine. I want to be able to go to path/to/file and give me index.php?url=path/to/file , which it does. However, it loads the actual PHP, it will not execute it in the browser. I am not sure what causes this.

Nginx Configuration:

 server { listen 80; server_name sandbox.domain.tld; access_log /path/to/domain/log/sandbox.access.log; error_log /path/to/domain/log/sandbox.error.log; location / { root /path/to/sandbox; index index.php; if (!-e $request_filename) { rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break; } } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /usr/local/nginx/conf/fastcgi_params; fastcgi_param SCRIPT_FILENAME /path/to/sandbox$fastcgi_script_name; } 
+8
php nginx
source share
1 answer

Try to change

rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break; to

rewrite ^/beta/(.+)$ /beta/index.php?url=$1 last; break;

Which should make nginx re-read the URI and process it accordingly.

+19
source share

All Articles