作者:Fuckkkkkkkkkk7777_352 | 来源:互联网 | 2014-05-28 09:40
cakephp部署在nginx的子目录cakephp部署在nginx子目录下的rewrite把app改名成相应的子目录名,两次rewritelocation/subdictionary/{indexindex.php;if(-e$request_filename){break;}if(!-e$request_filen
cakephp部署在nginx的子目录
cakephp部署在nginx子目录下的rewrite
把app改名成相应的子目录名,两次rewrite
location /subdictionary/ {
index index.php;
if (-e $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite ^/subdictionary/(.+)$ /subdictionary/webroot/$1 last;
break;
}
}
location /subdictionary/webroot/ {
index index.php;
if (-e $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite ^/subdictionary/webroot/(.+)$
/subdictionary/webroot/index.php?url=$1 last;
break;
}
}
cakephp在nginx上部署
因为nginx和apache的rewrite有差异,所以cakephp部署到nginx需要些小调整。
在nginx.conf的server里需添加下面这些
location / {
root /cakephp路径/app/webroot;
index index.php;
if (-e $request_filename) {
#文件或目录存在
break;
}
if (!-e $request_filename) {
#文件或目录不存在
rewrite ^/(.+)$
/index.php?url=$1 last;
break;
}
}
location ~ /\.ht { #禁止.htaccess
deny all;
}