Tagged: 404 Error on redirection
2013/12/28 at 11:25 pm #210
I’m using your book to try to learn ZF2, and I coded in the first controller chapter, but I get the 404 error when i browse to
So I git checkout ‘ch-first-controller’ and the code looks fine, but same problem – —
localhost/learnzf2/public works fine, and even after I replaced the indexController code for the Application module, it still works with the modified indexController
Can you help? – I on Ubuntu, using LAMP server
Gerald Clarke2014/01/01 at 9:51 pm #221
Hi Gerald, most probably 1)the .htaccess file is ignored or 2)you didn’t setup correct vhost file.
if 1) then you have to edit the apache configuration file to allow overriding of directives using .htaccess file. This is done via the AllowOverride directive.
if 2) then please tell me the full path where the application is located on the local hard disk and paste also the vhost file.2014/02/19 at 3:04 pm #249
I have a similar issue – actually it does work when using this URL:
The URL in the book (http://localhost/application/index/about) gives 404.
Although I think I followed the instructions of the book during installation, my localhost is still at C:/WAMP/www .
So the question is: after setting the new virtual host, is localhost supposed to be at C:/WAMP/www/learnzf2/public ?
(Obviously I have WAMP+Windows and know litte about Apache.)
Thanks, P M2014/02/28 at 1:35 am #264
On my machine I run ZendServer 6.3 on Windows 8.1 for development.
In the following directory c:\Zend\ZendServer\etc\sites.d\
i created a conf file named “vhost_learnzf2-local-80.conf” have to be exact with the name of this doc…
In it place…
<VirtualHost *:80> ServerName learnzf2.local ErrorLog "logs/learnzf2-local-error.log" CustomLog "logs/learnzf2-local-access.log" common DocumentRoot "c:\Zend\Apache2\htdocs\learnzf2.local\public" SetEnv APPLICATION_ENV "development" <Directory "c:\Zend\Apache2\htdocs\learnzf2.local\public"> DirectoryIndex Index.php AllowOverride All Order allow,Deny Allow from all </Directory> </VirtualHost>
If you dont use the “.local” then simply remove it from the Directory and Document Path.
Edit your Windows host doc located here;
Use Notepad++ our your choice to edit it. You may need to start your editor as an Administrator on Win8 to gain access to “write” so you can actually save it.
127.0.0.1 learnzf2 # if you prefer not to use the .local this works without it.
you will need to restart your apache
In ZendServer restart ZendServer via the ZendServer Control Panel or in a Command Prompt as an Administrator type in net stop Apache2.2-Zend wait til done then type net start Apache2.2-Zend
Now the following will work
assuming you are using the “.local” all below work
Ex 1. http://learnzf2.local/application/index/about
Ex 2. http://learnzf2.local/index.php/application/index/about
Ex 3. http://localhost/learnzf2.local/public/index.php/application/index/about
# # #
Below does not work
Ex 5. http://localhost/learnzf2.local/public/application/index/about
URI part as per the book “/application/index/about”
I think that as written on the book http://localhost likely refers to Ex 1. as configured above. To take the direct path to about.phtml you need Ex 3.
Other than the confusion as to whether to take the direct path or the VHost with Host record resolution without the index.php after /public the direct path does not route. Now this may be apache mod_rewrite issues on windows or its simply working as intended and the book expects Ex 1.
I hope this clarifies the issue with the author of the book and he can shed some light on this.
You must be logged in to reply to this topic.