Hi, I've been struggling with this issue for ages now. Feel like I've read every page of the docs 100 times!
I have a site running on nginx, there are two basic sections. First is a database-driven website (PHP/MySQL) using CodeIgniter. This is all working fine. Second is a Q&A forum running on Question2Answer (question2answer.org), in a subfolder /qa/. My original config is like this (inside the server block):
index index.php index.html;
# Q2A
if ($request_uri ~* "^/qa/") {
rewrite ^/qa/(.*)$ /qa/index.php?qa-rewrite=$1 last;
}
# CI
location / {
try_files $uri /index.php?$request_uri;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/mysite$fastcgi_script_name;
fastcgi_param HTTPS off;
}
(Sorry can't find how to do code formatting.)
The main problem is that static files (JSS, CSS, images) inside the /qa/ folder are not being served, the URLs are being passed to the Q2A app (where I get "page not found"). I've tried all sorts of permutations but nothing that works properly. For example if I do this, the index.php file gets served up for download!
location ~ /qa/(.*)? {
try_files $uri /qa/index.php?qa-rewrite=$1;
}
Apparently doing `if (!-e $request_filename) {}` is a really bad idea too.
Does anyone know how to get this working?!