Jump to content

Recommended Posts

The framework is set up and the index page is being displayed fine.  I'm trying to add navigation to the site and have hit a wall.  To add the contact.phtml view, I have done the following:

 

1.  Inside IndexController.php - added the contactAction() method.

2.  Added contact.phtml to /view/scripts/index

3.  Navigated to localhost/index/contact to see the results, but get "URL not found /index/contact"

 

My question:  Once the initial site framework is set up, what is the best way to add site navigation?

 

framework layout:

  |- application

|- bootstrap.php

|- config

|- config.ini

|- controllers

|- ErrorController.php

|- IndexController.php

|- data

|- db

|- models

|- logs

|- tmp

|- views

|- layouts

|- layout.phtml

|- scripts

|- error

|- error.phtml

|- index

|- index.phtml

|- contact.phtml

  |- library

|- Zend

  |- public

|- index.php

|- css

Link to comment
https://forums.phpfreaks.com/topic/134409-zend-framework-stuck-after-site-setup/
Share on other sites

  • 1 month later...

I'll have to assume that this "URL not found /index/contact" error you are receiving is a 404 error generated by your webserver/browser because it was unable to find the file '<documentroot>/index/contact' on disk.

 

It seems like you have configured your ZF app to handle index/contact correctly, so whats the problem?

 

Probably, it is because you have not instructed your webserver to 'redirect' all requests to your index.php file where they can be correctly handled by your ZF app.

 

For apache webservers, you would make use of the mod_rewrite module which allows you to do the above.

 

In your virtualhost config, or .htaccess, you would want something along the lines of:

 

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

 

Basically, this instructs Apache to rewrite all requests which would normally result in a 404 File Not Found back to your index.php for correct handling. There are several ways of doing this, but this is a good starting place.

 

This is actually covered in the ZF Quickstart Guide

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.