我玩弄的Nginx和安裝一個CMS系統,需要重寫,正常的代碼如下:nginx @rewrites目錄 - 不工作?
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/ /[email protected];
}
location /[email protected] {
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日誌中沒有錯誤。 任何想法我可能會做錯什麼?
:)不能忍受濫用nginx命名的位置。不過,你很有創意。呵呵。 –