Surendra Suthar Surendra Suthar - 1 year ago 80
PHP Question

Cakephp 2.4.5 Default Controller not loading

I am new in cakephp trying to loading default controller as Pages

This is my route :

Router::redirect ('/', array('controller' => 'pages', 'action' => 'display'));

Router::connect('/pages/**', array('controller' => 'pages', 'action' => 'display'));

When I run "http://localhost/project/index.php" then its working fine but try with "http://localhost/project/" its not loading default controller (Pages)

Without htaccess & with htaccess its giving same issue.

This is error:

Controller class ProjectController could not be found.


The requested address '/project/index.php/project/' was not found on
this server.

Answer Source

Its resolved

Added baseUrl in app controller:

function beforeRender(){
  $this->set('baseUrl', 'http://'.$_SERVER['SERVER_NAME'].Router::url('/'));

Removed App.baseUrl from Core.php :

Configure::write('App.baseUrl', env('SCRIPT_NAME'));

now its working fine on: http://localhost/app/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download