CakePHP in a subdirectory using nginx
I was facing many issues in setup cakephp3 in subfolder on nginx server.
I was doing changes in new server config while we have to do that in existing server config(well that work for me :) )
So I just add following in default config file. Which can be found
/etc/nginx/sites-available
location /youproj{
alias /usr/share/nginx/html/public_html/youproj/webroot;
if (-f $request_filename) {
break;
}
# prevent recursion
if ($request_uri ~ /webroot/index.php) {
break;
}
rewrite ^/youproj$ /youproj/ permanent;
rewrite ^/youproj/webroot/(.*) /youproj/webroot/index.php?url=$1 last;
rewrite ^/youproj/(.*)$ /youproj/webroot/$1 last;
}
And enable base_url in app.php in config folder of 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' => '/mamonde',
'fullBaseUrl' => false,
'imageBaseUrl' => 'img/',
'cssBaseUrl' => 'css/',
'jsBaseUrl' => 'js/',
'paths' => [
'plugins' => [ROOT . DS . 'plugins' . DS],
'templates' => [APP . 'Template' . DS],
'locales' => [APP . 'Locale' . DS],
],
],
No comments:
Post a Comment