The requested URL could not be matched by routing.

For programming and general questions on Zend Framework

The requested URL could not be matched by routing.

Postby vish808 on Fri Sep 06, 2013 7:53 am

Hi ,
I have set up zendframework 2 Skeleton Application in my local machine . Application is loading fine but when I access the URL as /index , it throws me the error as below
A 404 error occurred
Page not found.

The requested URL could not be matched by routing.
No Exception available

Im on Ububtu , Apache . Mod_rewrite is enabled .

Have not changed any code from .htaccess file
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]

AND in sites-available

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName dev2 dot localhost dot com
SetEnv APPLICATION_ENV "development"
DocumentRoot /var/www/dev2/public
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/dev2/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


Please suggest me , If I have made any error .
vish808
 
Posts: 1
Joined: Fri Sep 06, 2013 7:41 am

Re: The requested URL could not be matched by routing.

Postby clarkphp on Fri Sep 06, 2013 4:53 pm

Hello vish808,

If you look at module/Application/config/module.config.php, you'll see under the 'routes' key in the array that only the literal routes '/' and '/application' have been defined, with the additional child route of '/[:controller[/:action]]' defined underneath '/application'.

This means that only the following URLs will match the defined routes:
/
/application
/application/
/application/index
/application/index/index

Note that the segment route 'route' => '/[:controller[/:action]]', means that /application/index/ and /application/index/index/ (with a trailing slash) will NOT match and will result in a 404.

See the page
http://framework.zend.com/manual/2.2/en/modules/zend.mvc.routing.html
and
http://framework.zend.com/manual/2.2/en/user-guide/routing-and-controllers.html

Take your time, read it through carefully, and experiment a bit.
Best Regards,
Clark
User avatar
clarkphp
Zend Global Services
 
Posts: 28
Joined: Sat Jun 30, 2012 9:59 pm
Location: Tennessee, United States


Return to Zend Framework

Who is online

Users browsing this forum: Google [Bot] and 5 guests