Reputation: 2289
Here's the relevant nginx config (This is not a pure ZF app, rather ZF is embedded)
location /interface/modules/zend_modules/public/ {
root /interface/modules/zend_modules/public;
try_files $uri $uri/ $document_root/$uri $document_root/index.php$is_args$args;
}
location /interface/modules/zend_modules/public/(css|js|images)/ {
autoindex on;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /srv/app;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
http://example.com/interface/modules/zend_modules/public/Installer
successfully returns the page, but CSS, JS, and all images are returning 404
I just can't figure out how to get my static content to not get redirectred to index.php
(Static content is located in .../zend_modules/public/(css|js|images)
Upvotes: 1
Views: 131
Reputation: 49742
The first location block does not work the way you expect. It simply rewrites the URI to /interface/modules/zend_modules/public/index.php
because of your weird root
value.
The value for root
should be /srv/app
for all location
blocks, as nginx
constructs the pathname by concatenating the root
value with the URI. See this document for details.
You suggest that this server
implements multiple applications, so to restrict these locations to URIs which begin /interface/modules/zend_modules/public/
use nested locations and use the ^~
modifier. See this document for details.
For example:
location ^~ /interface/modules/zend_modules/public {
root /srv/app;
try_files $uri $uri/ /interface/modules/zend_modules/public/index.php$is_args$args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
}
EDIT:
If multiple applications are PHP based, and share the same root
, you could use something like this:
root /srv/app;
location /interface/modules/zend_modules/public {
try_files $uri $uri/ /interface/modules/zend_modules/public/index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
Upvotes: 1