私は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ログにエラーは発生しません。私が間違っているかもしれないアイデアはありますか?