Zend Framwork 2.2 standard route (/) could not be matched by routing

132 Views Asked by At

I've been looking for a solution for days but cannot find a solution. Help!

I've installed Zend Framework 2.2 and have implemented a MVC application with several routes, controllers and views. On my development system all is well. Locally I use a WAMP installation.

I transferred everything to my web provider (IIS8 with Helicon Ape) and got things working fine with the literal routes, e.g. www.url.nl/info.

The problem is that the standard route / doesn't work. I get a Zend 404 error message stating that "The requested URL could not be matched by routing".

I'm using the recommended standard literal route in module.config.php:

        ....
        'home' => array(
            'type' => 'Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'App\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),
        'info' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/info',
                'defaults' => array(
                    'controller' => 'App\Controller\Info',
                    'action'     => 'index',
                ),
            ),
        ),
        ....

and an unaltered public/.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

My own suspicion is aimed towards my provider running on IIS8.0 with Helicon Ape for support of Apache configuration files (.htaccess). In particular a web.config file is generated with default files under which index.php.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

I'm am also not able to use the complete url directly to /index.php. Same error.

Thanks in advance for any help.

Peter

1

There are 1 best solutions below

0
On

It is indeed IIS8, I've seen that before. But it's strange that default pages do not work for you. Try to add a rule on top of your .htaccess like:

RewriteRule ^$ /index.php [NC,L,NS]