我在玩 Nginx 并安装了一个需要重写的 cms 系统,正常的代码是:
location / { try_files $uri $uri/ @rewrites; }
location @rewrites {
rewrite ^/([^/\.]+)/([^/]+)/([^/]+)/? /index.php?page=$1&id=$2&subpage=$3 last;
rewrite ^/([^/\.]+)/([^/]+)/?$ /index.php?page=$1&id=$2 last;
rewrite ^/([^/\.]+)/?$ /index.php?page=$1 last;
}
但是这个 CMS 我安装在另一个名为 testcms 的目录中。所以我认为这会起作用:
location /testcms {
fastcgi_pass phpcgi;
fastcgi_index index.php;
try_files $uri $uri/ /testcms@rewrites;
}
location /testcms@rewrites {
rewrite ^/([^/\.]+)/([^/]+)/([^/]+)/? /testcms/index.php?page=$1&id=$2&subpage=$3 last;
rewrite ^/([^/\.]+)/([^/]+)/?$ /testcms/index.php?page=$1&id=$2 last;
rewrite ^/([^/\.]+)/?$ /testcms/index.php?page=$1 last;
}
但这会导致出现白页,并且 nginx 日志中没有错误。知道我可能做错了什么吗?