简体   繁体   中英

Zend Framework: The Requested Url was not found on this server

There seems to be a lot of similar issues around there but non that i've found that solve my version of the problem, im running the zend skeleton framework through the local osx web server.

resulting in the standard route being the following: http://localhost/~adam/api/public/

The route to the default index has been changed for the purpose of my application which works as intended:

     'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Testimonial',
                    'action'     => 'create',
                ),
            ),
        ),

When i create a new route, following the same idea it looks like this:

       'list' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/list',
                'defaults' => array(
                    'controller' => 'Application\Controller\Testimonial',
                    'action'     => 'list',
                ),
            ),
        ),

so it links to the same controller and in theory, i should just be able to access http://localhost/~adam/api/public/list and it should work however i get page not found.

I've seen people suggest that it could be to do with the .htaccess file which is currently as default:

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

I've also seen people suggest that you have to edit the /etc/apache2/httpd.conf file, to set AllowOverride all instead of AllowOverride none but either this doesn't work or i am doing it incorrectly, i've tried a few variations, ending up with this:

<Directory "/~adam/api/public">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

assuming this is the right fix i need, can someone point me out where im going wrong? or suggest how to fix this issue. As there are a few directory listings in the conf, is possible im changing the wrong one?

This problem caused by the routing match.

If you mentioned like 'route' => '/list', , then it looks from localhost. But, list is one module under your ~adam project.

To solve this issue, create a Virtual Host. If you are using Virutal Host then "/list" will look up from your (Virtual) Host name.

Otherwise, you have specify like this,

'route' => 'http://localhost/~adam/list'

But this is the bad approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM