I'm building a custom plugin and need to have a publicly accessible (non-CP) route as part of the plugin.

From what I've read I can use registerSiteRoutes() to register non-CP routes within my plugin. However, I'm getting a 404 when I do this. Here's my setup.


namespace Craft;

  class MyPlugin extends BasePlugin {


    public function registerSiteRoutes() {
      return array(
        'myroute'           => array('action' => 'myplugin/access/index')


namespace Craft;

class Portal_AccessController extends BaseController {

  protected $allowAnonymous = true;

  public function index() {

    $templatesPath = craft()->path->pluginsPath().'myplugin/templates/site/';




I have setup a basic template at /plugins/myplugin/templates/site/index.html

Hitting mydomain.com/myplugin results in a 404. Am I thinking of this correctly? Is it possible to have a non-CP route that points to a controller method in my plugin?

1 Answer 1


There are a couple of issues here:

  1. Any action methods in the controller class needs the "action" prefix to their name, i.e. actionIndex() for your "index" action, or actionLogin() for another action route calling "myPlugin/access/login".

In other words, rename your index() method in the controller to actionIndex(), and it should work.

  1. For action routes, plugin handles should be written in camelcase – i.e. "myPlugin/access/index", not "myplugin/access/index".

  2. You have a minor typo in the controller:

    $templatesPath = craft()->path->pluginsPath().'myplugin/templates/site/';

should read

$templatesPath = craft()->path->getPluginsPath().'myplugin/templates/site/';

Addendum: this might just be a typo in the question text, but your controller class is actually named "Portal_AccessController", so it will obviously not respond to the route "myPlugin/access/index" – the latter should read "portal/access/index" (or the controller should be renamed "MyPlugin_AccessController)

  • Not sure why this thing not working for me and keeps giving Unable to resolve the request
    – Volatil3
    Oct 20, 2015 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.