When going on example.com
, example.com/foo/
or example.com/foo/bar/
, PHP was working great. Then I tried to modify Nginx conf to have foo.example.com
pointing on example.com/foo/
(the DNS is already configured). It works, but now when I access to foo.example.com/bar/
, I can download foo/bar/index.php
instead of executing it.
Here is the Nginx configuration:
server {
listen 80;
server_name *.example.com;
root /var/www/html/;
location / {
index index.html;
}
}
server {
listen 80;
server_name foo.example.com;
root /var/www/html/foo/;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass web_fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I know there are plenty of similar threads, but none of those I read worked.