Getting 404 error after 'ch-first-controller'

Home Forums Learn ZF2 Getting 404 error after 'ch-first-controller'

This topic contains 3 replies, has 4 voices, and was last updated by  getvma@live.com 3 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #210

    Hi
    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
    http://localhost/learnzf2/index/about
    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
    thanks
    Gerald Clarke

    #221

    admin
    Keymaster

    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.

    #249

    zimzum74@gmail.com
    Participant

    Hi All,

    I have a similar issue – actually it does work when using this URL:
    http://localhost/learnzf2/public/application/index/about .
    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 M

    #264

    getvma@live.com
    Participant

    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;
    C:\Windows\System32\drivers\etc\hosts
    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.

    Add
    127.0.0.1 learnzf2.local
    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.

    Vic

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.