Yii Framework - Routing is not working

Currently developing web service using yii framework but routing is not working as expected.

This is the expected route to call web service. "api" is ApiController, "totalviews" is actionTotalviews.


The default route will direct to login controller and actionIndex. But I tried the below to expected route but 404 not found.




Appreciate your assistance!

More details: stackoverflow.com/questions/44390316/yii-framework-routing-is-not-working

What does your controller look like?

Ruote name depends on the http server and yii configuration (enabling rewrite rules and enablimg pretty urls) and on controller and action name case .

From your stackoverflow post it seem you are working with URL rewrite and pretty URL.

If pretty URL is properly configured thinks like:


Do not work.

The first part of the route depends on your http configuration.

Yii advanced template has 3 application already configured: backend, frontend, console

Console is for the command line, the other 2 are for web.

The web application have same dir structure and http webroot should point to web directory

So something like


Where myproject is yii installation and backend is the web application, the webroot is


And in the browser is


For basic application template, where there is only the web application, the webserver configuration should point to web directory as well.

So assuming that your configurations (both http server and pretty urls) are correct, your controller name is ApiController and your action name is actionTotalviews, the URl is http://localhost/api/totalviews.

Yii manage 404 errors internally and the message looks different from webserver one, if the message you get is from webserver your webserver configuration is wrong.