Hey!
I have question about Zend Framework, and specifically Zend Controller. I'm reading "Practical Web 2.0 Applications with PHP" book, and I have the books code and I seem to have all the setting right. But for some reason when I try to access say http://localhost/account/register or any other location for that matter (only http://localhost works fine) then I always get a 404 File Not Found Error. I think there is something wrong with the Controller since it's the controller that uses this method of class and action names for URLs. Can anyone help or suggest a solution?
Thanks in advance!
PHP5 - Zend Controller
Moderator: General Moderators
Re: PHP5 - Zend Controller
Are you using mod_rewrite? (Assuming your using apache)
Try http://localhost/index.php/account/register
Try http://localhost/index.php/account/register
Re: PHP5 - Zend Controller
Yeah, I'm using rewrite and apache.
Thanks a lot for the advice, localhost/index.php/account/register works! How can I make it work without the index.php in between?
Thanks!
Thanks a lot for the advice, localhost/index.php/account/register works! How can I make it work without the index.php in between?
Thanks!
Re: PHP5 - Zend Controller
What does your .htaccess look like?
Zend Framework Docs wrote:7.1.2.3. Create your rewrite rules
Edit the html/.htaccess file above to read as follows:
The above rules will route any non-resource (images, stylesheets) requests to the front controller. If there are other extensions you wish to exclude from the front controller (PDFs, text files, etc), add their extensions to the switch, or create your own rewrite rules. pRewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Re: PHP5 - Zend Controller
This is how my .htaccess file looks like:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
And if I don't use it (AllowOverride None) then stuff works only through index.php (http://localhost/index.php/account/register), but if I use Allow Override All, then I always get a 500 Internal Server Error, which is part of the Zend Framework. Any ideas what to do?
Thanks!!
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
And if I don't use it (AllowOverride None) then stuff works only through index.php (http://localhost/index.php/account/register), but if I use Allow Override All, then I always get a 500 Internal Server Error, which is part of the Zend Framework. Any ideas what to do?
Thanks!!
Re: PHP5 - Zend Controller
The 500 Error leads me to think that most likely mod_rewrite isn't installed/enabled right.
Look in your apache log files.
Look in your apache log files.
Re: PHP5 - Zend Controller
Thanks so much! Yeah, it wasn't included in the httpd.conf file. It took me 5 secs to fix that!
Help greatly appreciated!
Help greatly appreciated!