[英]Cakephp 3 not working properly on ngnix
I am quite new on nginx
server. 我在nginx
服务器上很新。 Recently I have change my server from apache
to nginx
and move the code into a subfolder for testing purpose. 最近,我将服务器从apache
更改为nginx
,并将代码移到子文件夹中以进行测试。 Now I am facing issue of 404 not found
for sub pages, css, js and images. 现在,我面临子页面,CSS,JS和图像404 not found
的404 not found
问题。 Code is in cakephp V3
. 代码在cakephp V3
。
Here is my nginx config 这是我的nginx配置
# You may add here your
server {
location /myproj{
alias /usr/share/nginx/html/public_html/myproj/webroot;
if (-f $request_filename) {
break;
}
# prevent recursion
if ($request_uri ~ /webroot/index.php) {
break;
}
rewrite ^/myproj$ /myproj/ permanent;
rewrite ^/myproj/webroot/(.*) /myproj/webroot/index.php?url=$1 last;
rewrite ^/myproj/(.*)$ /myproj/webroot/$1 last;
}
}
and cakephp
config is 和cakephp
配置是
'App' => [
'namespace' => 'App',
'encoding' => env('APP_ENCODING', 'UTF-8'),
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),
'base' => false,
'dir' => 'src',
'webroot' => 'webroot',
'wwwRoot' => WWW_ROOT,
'baseUrl' => env('SCRIPT_NAME'),
'base' => '/myproj',
'fullBaseUrl' => false,
'imageBaseUrl' => 'img/',
'cssBaseUrl' => 'css/',
'jsBaseUrl' => 'js/',
'paths' => [
'plugins' => [ROOT . DS . 'plugins' . DS],
'templates' => [APP . 'Template' . DS],
'locales' => [APP . 'Locale' . DS],
],
],
Edit : I managed to run that, I move location /myproj{
under already created server {
settings and comment the one I have created. 编辑:我设法运行它,我将location /myproj{
移动到已经创建的server {
设置下,并注释我创建的server {
。 Thanks 谢谢
Try adding this in to the config file 尝试将其添加到配置文件中
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.