I have created a try_files directive that tries files in a different directory than the files are put in. I.e., if I visit www.example.com/home/main it will try the file /var/www/main/home/main.php. It works, but when I visit a page, it only shows the PHP source code and not the processed page. Here is my directive:
location ~ /home/ {
index main.php
try_files /main$uri.php @404;
location \.php {
fastcgi_pass php_server;
include fastcgi_params;
}
}
Any ideas on how I can get the page to process instead of just showing the PHP source?
Edit for additional information: I have tried making a location directive that looks like
location ~ /main/(.*)\.php {
fastcgi_pass php_server;
include fastcgi_params;
}
but this doesn't work either and the pages still show just the source code.
location ~ \.phpto process PHP files in the root directory, and those work fine.