Reputation: 9878
I create a module in zend project and the module has it's own mvc folders, here's the structure of the module,
i want to open the index page which located in the view floder of the visit module
here's the path of the index.phtml
InspectionSys\application\modules\visits\views\scripts\visits\index.phtml
and I try to make routing to the index page in application.ini
resources.router.routes.user.route = /visit
resources.router.routes.user.defaults.module = visits
resources.router.routes.user.defaults.controller = visit
resources.router.routes.user.defaults.action = index
when I type http://localhost/zendApps/InspectionSys/visit it returns 404 error page.
What should I do?
Upvotes: 1
Views: 370
Reputation: 79039
Your controller's name is visits
not visit
.
Try replacing your route with this
resources.router.routes.user.route = "/visit"
resources.router.routes.user.defaults.module = visits
resources.router.routes.user.defaults.controller = visits
resources.router.routes.user.defaults.action = index
or define your route in bootsrap
$routeUser = new Zend_Controller_Router_Route(
'/visit',
array(
'module' => 'visits'
'controller' => 'visits',
'action' => 'index'
)
);
$router -> addRoute('visit', $routeUser);
The problem seems to be due to the root not being routed to /public
.
The proper way: You need to setup a vhost and point the root to the public
directory.
Another Way: You need to redirect every request inside public
directory. The .htaccess
for this file would be
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Upvotes: 2