Default route controller / action and links to css / js do not work cakephp

0

After extracting cake 2.5.2 to the directory (Linux) /var/www/html/teste when accessing the url http://localhost/teste it loads the content correctly from the controller pages and action display conforms to the file routes.php :

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

However when trying to access the controller directly through the url:

http://localhost/teste/pages/display I got the 404 return from Page not found.

Apart from this (rs), the files of css/js/img of the webroot folder (not being included by the generated url) are not loaded.

Generated url that returns file not found:

http://localhost/teste/css/cake.generic.css

Url to access the file correctly:

http://localhost/teste/app/webroot/css/cake.generic.css

My solution to the css / js / img files was as follows, I changed the way to call the file.

Standard used form:

echo $this->Html->css('cake.generic');

New form:

echo $this->Html->css('/app/webroot/css/cake.generic.css');

In short, I think maybe the error really is in apache or something, but I'm not exactly sure how I can validate that part.

My solution for css / js / img, is it correct? Well I think it was to function as the example I downloaded in the cake version correctly.

If you need more information just talk, thanks.

    
asked by anonymous 02.07.2014 / 16:21

1 answer

1

You need to call the views of PagesController like this:

http://localhost/teste/pages/home

The method display does not return view, you request directly in the url the view you want to display, after the /pages/sua_view controller.

As for css / js / img, it's usually just like this:

echo $this->Html->css(array('forms', 'tables', 'menu'));

Will output:

<link rel="stylesheet" type="text/css" href="/css/forms.css" />
<link rel="stylesheet" type="text/css" href="/css/tables.css" />
<link rel="stylesheet" type="text/css" href="/css/menu.css" />

If this is not happening, it may be that your server is not properly configured to use the cake.

Take a look here: link

    
02.07.2014 / 17:44