Zend Framework Path Problems

2019-07-16 18:08发布

All,

I am just trying to view any page at all besides the “Welcome to Zend Framework” screen.

I have downloaded the project from this tutorial: http://framework.zend.com/docs/quickstart/create-a-form (Zend Framework Quickstart)

As far as I can tell, the paths are coming up correctly. I read this post: http://www.johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/ I think it may be a bit dated, as the bootstrap code is not as he describes.

Does anyone have any ideas? I would think that the tutorial download from Zend should work out of the box.

Summary: http://localhost/ZendFrameworkQuickstart/public/ Displays: Zend welcome page

http://localhost/ZendFrameworkQuickstart/public/guestbook Displays: 404

Thanks!

UPDATE Physical path of the “public” directory: C:\Zend\Apache2\htdocs\ZendFrameworkQuickstart\public

URL I’m hitting from the browser: http://localhost/ZendFrameworkQuickstart/public/guestbook

.htaccess Contents:

SetEnv APPLICATION_ENV development

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /ZendFrameworkQuickstart/Public/index.php [NC,L]

UPDATE: Changed lines in files

.htaccess RewriteRule ^.*$ /ZendFrameworkQuickstart/public/index.php [NC,L]

application.ini resources.frontController.baseUrl = "/ZendFrameworkQuickstart/public"

public/index.php error_reporting( E_ALL | E_STRICT ); ini_set( 'display_errors', 1 );

2条回答
戒情不戒烟
2楼-- · 2019-07-16 18:21

Finally figured it out. In the httpd.conf file for Apache, change every instance of "AllowOverride None" to "AllowOverride All."

I'm not sure why Zend didn't have this setup already, since my Zend Framework install setup Apache. After this change, the Quickstart ran as-is (and didn't even need to be in the root).

Thanks for all of the help!

查看更多
小情绪 Triste *
3楼-- · 2019-07-16 18:27

Adding to Jacob's comment: I think the mod_rewrite conditions and rules in the .htaccess file for the Quickstart application expect everything to be relative to the root of the domain and particularly rewrites everything to the root of the domain (/index.php to be specific).

So either:

  • adjust the rewrite conditions and rules in the .htaccess, or
  • let the root of the (virtual) host point directly to the public folder of the Quickstart application.

Also, be sure you have mod_rewrite enabled on your server (assuming you have an apache server).

EDIT Since your application is not running from the root of your server you should probably still set the baseUrl somewhere in your bootstrap. With something like:

$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl( '/ZendFrameworkQuickstart/public' );

But you'll be saving yourself a lot of trouble to just circumvent this by putting your application in the root of your server, or let the root of your server point to the public folder in httpd.conf, if either of these options is available to you.

If you do this, be sure to put the .htaccess to it's default settings again.

查看更多
登录 后发表回答