Answers.Body: <p>You're getting a 404 because your action method isn't telling Craft what do to after it has echo'd 'Here', so <a href="http://buildwithcraft.com/docs/routing" rel="nofollow">routing</a> continues.</p>
  
  <p>See #3 is that link:</p>
  
  <pre><code>The request doesn’t necessarily end after a controller has been called. The controller may allow it to keep going.
  </code></pre>
  
  <p>You can redirect, end the request, load up a template to display, etc.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>The <code>controller</code> folder needs to be renamed to <code>controllers</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T21:56:49.280Z
Answers.Text: So if I put something like `$this->redirect('http://google.com');` in my controller method it should redirect, but I'm still being returned to `/pro-portal` and getting the 404 page.
Answers.UserDisplayName: Brett DeWoody
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T22:09:03.520Z
Answers.Text: If you put a `die();` after the echo, do you see the text?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T22:10:06.677Z
Answers.Text: No. I get the 404 page.
Answers.UserDisplayName: Brett DeWoody
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T22:11:31.363Z
Answers.Text: Oh, it's not even making it to the action then. Rename your `controller` folder to `controllers`.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T22:13:14.773Z
Answers.Text: I knew it would be something simple like that. Thank you!
Answers.UserDisplayName: Brett DeWoody
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T21:51:56.430Z
Answers.LastActivityDate: 2015-03-05T22:13:50.947Z
Answers.LastEditDate: 2015-03-05T22:13:50.947Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm working on a plugin and need a front-end (non CP) form that submits to one of the plugin controllers. Here's my setup:</p>
  
  <pre><code>- plugins
    - portal
      -- PortalPlugin.php
      - controller
        -- Portal_AccessController.php
  </code></pre>
  
  <p><strong>Portal_AccessController.php</strong></p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class Portal_AccessController extends BaseController {
  
      protected $allowAnonymous = true;
  
      public function actionLogin() {
  
          echo 'Here';
  
      }
  
  }
  </code></pre>
  
  <p>I then created a front-end form by adding a new template directory in <code>/craft/templates</code>:</p>
  
  <pre><code>- pro-portal
    -- index.html
  </code></pre>
  
  <p>With <code>index.html</code> containing:</p>
  
  <pre><code>&lt;form method="post" action="" accept-charset="UTF-8"&gt;
      &lt;input type="hidden" name="action" value="portal/access/login"&gt;
  
      &lt;div&gt;
          &lt;input type="text" maxlength="4"&gt;
          &lt;input type="text" maxlength="4"&gt;
          &lt;input type="text" maxlength="4"&gt;
          &lt;input type="text" maxlength="4"&gt;
      &lt;/div&gt;
      &lt;a href="{{ actionUrl('portal/access/login') }}"&gt;Test me&lt;/a&gt;
      &lt;input class="btn submit" type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Hitting <code>mydomain.com/pro-portal</code> displays the form. On submit it returns to <code>/pro-portal</code> but with a 404 error. </p>
  
  <p>I also tried creating an action link but that also results in a 404 at <code>/index.php/actions/portal/access/login</code>.</p>
  
  <p>I've looked through answers on similar questions and tried all the solutions but no luck. Am I overlooking something? Missing something?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-05T21:43:59.057Z
Comments.Text: What's `$response['redirect']` and where is it coming from?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-05T21:46:37.090Z
Comments.Text: I tried passing in a redirect parameter to redirect to a new URL. That's not in my code at the moment. I've update the question to show that.
Comments.UserDisplayName: Brett DeWoody
Tags: <plugin-development><form>
Title: Posting front-end form to plugin controller route results in 404
ThreadText: # Posting front-end form to plugin controller route results in 404
  
  (Asked by: username_0 on 2015-03-05)
  
  I'm working on a plugin and need a front-end (non CP) form that submits to one of the plugin controllers. Here's my setup:
  
  ```
  - plugins
    - portal
      -- PortalPlugin.php
      - controller
        -- Portal_AccessController.php
  
  ```
  
  **Portal\_AccessController.php**
  
  ```
  <?php
  namespace Craft;
  
  class Portal_AccessController extends BaseController {
  
      protected $allowAnonymous = true;
  
      public function actionLogin() {
  
          echo 'Here';
  
      }
  
  }
  
  ```
  
  I then created a front-end form by adding a new template directory in `/craft/templates`:
  
  ```
  - pro-portal
    -- index.html
  
  ```
  
  With `index.html` containing:
  
  ```
  <form method="post" action="" accept-charset="UTF-8">
      <input type="hidden" name="action" value="portal/access/login">
  
      <div>
          <input type="text" maxlength="4">
          <input type="text" maxlength="4">
          <input type="text" maxlength="4">
          <input type="text" maxlength="4">
      </div>
      <a href="{{ actionUrl('portal/access/login') }}">Test me</a>
      <input class="btn submit" type="submit" value="Submit">
  </form>
  
  ```
  
  Hitting `mydomain.com/pro-portal` displays the form. On submit it returns to `/pro-portal` but with a 404 error.
  
  I also tried creating an action link but that also results in a 404 at `/index.php/actions/portal/access/login`.
  
  I've looked through answers on similar questions and tried all the solutions but no luck. Am I overlooking something? Missing something?
  
  **Tags:** plugin-development, form
  
  > **Comments:**
  > **username_1**: What's `$response['redirect']` and where is it coming from?  
  > **username_0**: I tried passing in a redirect parameter to redirect to a new URL. That's not in my code at the moment. I've update the question to show that.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-05. Score: 0 | Accepted answer
  
  You're getting a 404 because your action method isn't telling Craft what do to after it has echo'd 'Here', so [routing](http://buildwithcraft.com/docs/routing) continues.
  
  See #3 is that link:
  
  ```
  The request doesn’t necessarily end after a controller has been called. The controller may allow it to keep going.
  
  ```
  
  You can redirect, end the request, load up a template to display, etc.
  
  **Update:**
  
  The `controller` folder needs to be renamed to `controllers`.
  
  > **Comments:**
  > **username_0**: So if I put something like `$this->redirect('http://google.com');` in my controller method it should redirect, but I'm still being returned to `/pro-portal` and getting the 404 page.  
  > **username_1**: If you put a `die();` after the echo, do you see the text?  
  > **username_0**: No. I get the 404 page.  
  > **username_1**: Oh, it's not even making it to the action then. Rename your `controller` folder to `controllers`.  
  > **username_0**: I knew it would be something simple like that. Thank you!  
  
  ---
  
  