I am trying to port this rule to nginx and have the following:
server {
listen 80;
server_name app.mydomain.com;
if ($host = 'app.mydomain.com') {
rewrite ^[^.]*$ controller.php/$1 last;
}
root /srv/www/domains/app.mydomain.com;
index index.php;
access_log /var/log/nginx/domains/app.mydomain.com/access.log;
error_log /var/log/nginx/domains/app.mydomain.com/error.log;
include /etc/nginx/excludes.conf;
include /etc/nginx/php.conf;
include /etc/nginx/expires.conf;
}
The problem is that the rewrite rule for nginx is not working correctly?
Any idea what I am doing wrong?
Thanks for the tip on removing the if block. So, perhaps the regular
expression is off? Basically, the rewrite-rule should fire if the url
does NOT contain a period.
Examples:
/some/path //should hit the rewrite rule
/file.php //should NOT hit the rewrite rule
2012/07/25 23:05:12 [error] 1040#0: *1 FastCGI sent in stderr:
“Access to the script ‘/srv/www/domains/app.mydomain.com/’ has been
denied (see security.limit_extensions)” while reading response
header from upstream, client: XXX.XXX.XXX.91, server: app.mydomain.com, request: “GET / HTTP/1.1”, upstream:
“fastcgi://127.0.0.1:9000”, host: “app.mydomain.com”
Any idea what that means?
Yes. It means that the file that you’re trying to access has an
extension that your PHP runtime config forbids. You must enable that
extension by setting the security.limit_extensions parameter.
2012/07/25 23:05:12 [error] 1040#0: *1 FastCGI sent in stderr: “Access
to the script ‘/srv/www/domains/app.mydomain.com/’ has been denied (see
security.limit_extensions)” while reading response header from upstream,
client: XXX.XXX.XXX.91, server: app.mydomain.com, request: “GET /
HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host:
“app.mydomain.com”
Work. However, took a peak at the error log and found this:
2012/07/25 23:05:12 [error] 1040#0: *1 FastCGI sent in stderr: “Access
to the script ‘/srv/www/domains/app.mydomain.com/’ has been denied (see
security.limit_extensions)” while reading response header from upstream,
client: XXX.XXX.XXX.91, server: app.mydomain.com, request: “GET /
HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host:
“app.mydomain.com”
Same thing, access denied. How does Wordpress and PHP 5.4 with Nginx
work with permalinks? It would seem it would have the same problem since
the paths are like: