Problems to define new route

Asked

Viewed 57 times

2

I can’t access my controllers through the url. I already set the routes, but from what I saw, instead of calling the Controller I put in the url it’s calling the action

AN EX:

Router::connect('/home/*', array('controller' => 'agendas', 'action' => 'index'));

when access localhost/myfolder/home it returns an error message saying to create the action home

It only accesses this Controller if you put the url as follows localhost/mina_folder/index.php/agendas/home

  • Try removing the /*. And another, your controller flame really agenda? Usually used in the plural.

  • typo, but it still didn’t work. I’ll edit the question, to put some more details

  • I’ve had this problem before. Fortunately, I solved it. See my answer

1 answer

0

Your apache (or whatever server you use) may not be reading yours .htaccess or even there is no .htaccess

You said he accesses when you put

minha_pasta/index.php/controller/ação

To work that way:

minha_pasta/controller/ação

You must define your .htaccess thus (at the root of the application)

RewriteEngine On

RewriteRule ^(.*)$ index.php/$1

If you are having trouble reading the htaccess, may change your vhosts.conf and place the following instruction:

<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all
   Order allow,deny
   allow from all
</Directory>

If in case you are using Windows, the section where is /var/www should be replaced by C:\\Windows\\xampp\\htdocs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.