Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 837 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Zend Framework: only index view renders 404 error when trying to access other views via /controller/action url

#1
I am new to Zend Framework.

I am running Apache 2.2 and have set the DocumentRoot in the httpd.conf file to the public directory created using Zend_Tool.

Within the public directory I have an .htaccess file;

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

...and an index.php file;

<?php

// Define path to application directory
/*defined('APPLICATION_PATH')
|| */define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);

$application->bootstrap()->run();

When I type "http://localhost/" into the browser the file index.phtml in the "application/views/scripts/index/" directory is rendered ok.

If I try to access other views using the controller and action names in a url I get a 404 error saying that the requested URL could not be found on the server.

For example I have the controller file TestController.php
which is in the same directory as IndexController.php

/*TestController.php*/

<?php

class TestController extends Zend_Controller_Action
{

public function init()
{
/* Initialize action controller here */
}

public function testAction()
{
// action body
}


}

I have created a test directory containing a file called index.phtml in "application/views/scripts/";

/*views/scripts/test/index.phtml*/

<br /><br />
<div id="view-content">
<p>View script for controller <b>Test</b> and script/action name <b>index</b></p>
</div>

When I try to render this file by typing "http://localhost/test/" I get a 404 error stating that the requested URL could not be found. All of the Zend Framework documentation I have read and countless other resources all state that this method should render correctly.

I must be missing something, but after an exhaustive search have been unable to find anyone else having this particular problem.

Regards Roan

Reply

#2
try creating an indexAction in the test controller... or test.phtml in the directory
Reply

#3
Can you check if the second url localhost/test is going through your index.php.
You can put a die() or some debug statement for that.

Reply

#4
Hmm try to add this in your httpd.conf file:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot Link to yourSiteFolder exp. C:/AppServ/www/yourSite/public
ServerName youServerName exp.

[To see links please register here]

or you ip

[To see links please register here]

</VirtualHost>

<Directory "Link to yourSiteFolder exp. C:/AppServ/www/yourSite/public">
Options FollowSymLinks
AllowOverride All
</Directory>

Find this:

#LoadModule rewrite_module modules/mod_rewrite.so

And delete '#'.

Reply

#5
Thanks for your replies.

Thought I would post my solution for others..

Here is the section I updated in the httpd.conf file within the directory tags;

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

and I had previously uncommented the module mentioned above

LoadModule rewrite_module modules/mod_rewrite.so

Cheers

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through