<p>You need to use <code>/actions</code> (or whatever your Trigger word is) to access Controller actions.</p>

<p>Documentation: <a href="http://buildwithcraft.com/docs/config-settings#actionTrigger" rel="nofollow">http://buildwithcraft.com/docs/config-settings#actionTrigger</a></p>

<p><strong>EDIT:</strong> I realize I wasn't clear enough; this variable defaults to <code>/actions</code>. Unless you've set it to something else in your Config, add the <code>/actions</code> to your URL to access the Controller action.</p>

<p>So, your URL would be this: <code>http://domain.craft.dev/actions/PluginHandle/Duh/foo</code></p>

<p>Note that <strong>capitalization matters.</strong></p>

<p>It's also important to make sure that if you plan on making calls to this URL from outside Craft, you'll need to make sure that you're allowing anonymous access by setting that variable at the top of your controller:</p>

<p><code>protected $allowAnonymous = true;</code></p>

CC BY-SA 3.0
2015-10-20T17:14:35.973Z
My Config does not have any such entry.
Volatil3
CC BY-SA 3.0
2015-10-21T06:57:13.430Z
the default action trigger is 'actions' so there doesn't need to be anything in your config. just try hitting `/actions/db/dauh/foo`
Luke Holder
CC BY-SA 3.0
2015-10-20T17:00:04.977Z
2015-10-21T20:53:56.267Z
2015-10-21T20:53:56.267Z
Taylor Daughtry
<p>So I am working on it first time. I created a Controller <code>DB_DuhController</code> having a method <code>actionFoo()</code></p>

<p>I am then calling it as <code>http://domain.craft.dev/admin/DB/duh/Foo</code> but it's giving <code>404</code> all the time. What is wrong being done by me?</p>

CC BY-SA 3.0
2015-10-20T09:39:02.090Z
Should it be `/admin/db/duh/foo` with lower case db? I think the plugin name is lowercase for first letter: http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing same with action name `foo` not `Foo`. Also assume you have a CP route in place for the `/admin` request.
Luke Holder
CC BY-SA 3.0
2015-10-20T10:25:56.780Z
`/admin` is working but not after that.
Volatil3
CC BY-SA 3.0
2015-10-20T10:27:22.643Z
post your cp route.
Luke Holder
CC BY-SA 3.0
2015-10-20T10:27:27.253Z
My `hookRegisterCpRoutes` method is empty. Do I need to define routes first?
Volatil3
CC BY-SA 3.0
2015-10-20T10:29:12.710Z
Yes unless you are accessing it with the /actions url
Luke Holder
CC BY-SA 3.0
2015-10-20T10:32:44.650Z
you mean `http://domain.craft.dev/admin/DB/duh/actions/Foo`?
Volatil3
CC BY-SA 3.0
2015-10-20T10:54:12.980Z
I did this: `DB/duh/list' => array('action' => 'db/_list')` and it says: `Unable to resolve the request "duh/list".
Volatil3
CC BY-SA 3.0
2015-10-20T11:17:53.387Z
@LukeHolder there?
Volatil3
<plugin-development><routing>
Craft Controller gives 404 error
# Craft Controller gives 404 error

(Asked by: username_0 on 2015-10-20)

So I am working on it first time. I created a Controller `DB_DuhController` having a method `actionFoo()`

I am then calling it as `http://domain.craft.dev/admin/DB/duh/Foo` but it's giving `404` all the time. What is wrong being done by me?

**Tags:** plugin-development, routing

> **Comments:**
> **username_1**: Should it be `/admin/db/duh/foo` with lower case db? I think the plugin name is lowercase for first letter: http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing same with action name `foo` not `Foo`. Also assume you have a CP route in place for the `/admin` request.  
> **username_0**: `/admin` is working but not after that.  
> **username_1**: post your cp route.  
> **username_0**: My `hookRegisterCpRoutes` method is empty. Do I need to define routes first?  
> **username_1**: Yes unless you are accessing it with the /actions url  
> **username_0**: you mean `http://domain.craft.dev/admin/DB/duh/actions/Foo`?  
> **username_0**: I did this: `DB/duh/list' => array('action' => 'db/_list')` and it says: `Unable to resolve the request "duh/list".  
> **username_0**: @LukeHolder there?  

---

## 1 answers

### Answer by username_2 on 2015-10-20. Score: 2

You need to use `/actions` (or whatever your Trigger word is) to access Controller actions.

Documentation: <http://buildwithcraft.com/docs/config-settings#actionTrigger>

**EDIT:** I realize I wasn't clear enough; this variable defaults to `/actions`. Unless you've set it to something else in your Config, add the `/actions` to your URL to access the Controller action.

So, your URL would be this: `http://domain.craft.dev/actions/PluginHandle/Duh/foo`

Note that **capitalization matters.**

It's also important to make sure that if you plan on making calls to this URL from outside Craft, you'll need to make sure that you're allowing anonymous access by setting that variable at the top of your controller:

`protected $allowAnonymous = true;`

> **Comments:**
> **username_0**: My Config does not have any such entry.  
> **username_1**: the default action trigger is 'actions' so there doesn't need to be anything in your config. just try hitting `/actions/db/dauh/foo`  

---

