我玩弄的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命名的位置。不过,你很有创意。呵呵。 –