Answers.Body: <p>I think your URL is wrong. </p>
  
  <p>Try <code>/index.php/actions/sitemap/sitemap/xml</code></p>
  
  <p>Here is the section of the docs that explains URLs for plugin controllers: <a href="http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing" rel="nofollow">http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T12:23:06.037Z
Answers.Text: The url should be fine. I'm able to access it when logged in. This is also the url returned by actionUrl. The plugin in questions is named Sitemap, and has a single controller called SitemapController.
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T12:50:19.910Z
Answers.Text: This answer should be correct. The "admin" segment is the reason you're redirected to the CP login; remove it and you should be fine.  Also, where are you calling ```actionUrl```? I just tested it in a frontend template, and it didn't prepend w/ "admin" on my end.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T16:19:16.540Z
Answers.Text: I believe the `siteMap` in the url needs to be camel-cased... This is a situation where the path isn't indicating a _directory_, it's indicating a _plugin class_ for the action routing to follow.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T16:20:59.700Z
Answers.Text: Nevermind, I see "Sitemap" in your controller name is all lowercase.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T20:23:31.747Z
Answers.Text: You were right - I was using a url returned from actionUrl within the admin, and forgot to remove the admin segment. Works superduper now.
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T12:21:01.050Z
Answers.LastActivityDate: 2015-03-31T13:22:07.150Z
Answers.LastEditDate: 2015-03-31T13:22:07.150Z
Answers.UserDisplayName: Aaron Berkowitz
Body: <p>I have this controller, and I've set $allowAnonymous to true, but I'm still getting redirect to CP login:</p>
  
  <pre><code>class SitemapController extends BaseController
  {
      protected $allowAnonymous = true;
  
      public function actionXml()
      {
          ...
          $this-&gt;renderTemplate('sitemap/list.xml', array(
              'entries' =&gt; $entries,
              'sections' =&gt; $enabledSections
          ));        
      }
  
  }
  </code></pre>
  
  <p>Is there anything I'm missing?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-31T11:23:50.593Z
Comments.Text: What does your route look like?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-31T11:25:34.163Z
Comments.Text: No routes setup for this plugin. Trying to access it through the action url, like so: /index.php/admin/actions/sitemap/xml
Comments.UserDisplayName: Fred Carlsen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-31T11:33:53.840Z
Comments.Text: Beats me. Your code looks legit. What happens if you remove everything inside ```actionXml()``` and just ```die( 'something' )```?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-31T11:41:47.083Z
Comments.Text: Still redirects.
Comments.UserDisplayName: Fred Carlsen
Tags: <controller>
Title: Anonymous access to controller action fails
ThreadText: # Anonymous access to controller action fails
  
  (Asked by: username_0 on 2015-03-31)
  
  I have this controller, and I've set $allowAnonymous to true, but I'm still getting redirect to CP login:
  
  ```
  class SitemapController extends BaseController
  {
      protected $allowAnonymous = true;
  
      public function actionXml()
      {
          ...
          $this->renderTemplate('sitemap/list.xml', array(
              'entries' => $entries,
              'sections' => $enabledSections
          ));        
      }
  
  }
  
  ```
  
  Is there anything I'm missing?
  
  **Tags:** controller
  
  > **Comments:**
  > **username_1**: What does your route look like?  
  > **username_0**: No routes setup for this plugin. Trying to access it through the action url, like so: /index.php/admin/actions/sitemap/xml  
  > **username_1**: Beats me. Your code looks legit. What happens if you remove everything inside ```actionXml()``` and just ```die( 'something' )```?  
  > **username_0**: Still redirects.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-03-31. Score: 4 | Accepted answer
  
  I think your URL is wrong.
  
  Try `/index.php/actions/sitemap/sitemap/xml`
  
  Here is the section of the docs that explains URLs for plugin controllers: <http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing>
  
  > **Comments:**
  > **username_0**: The url should be fine. I'm able to access it when logged in. This is also the url returned by actionUrl. The plugin in questions is named Sitemap, and has a single controller called SitemapController.  
  > **username_1**: This answer should be correct. The "admin" segment is the reason you're redirected to the CP login; remove it and you should be fine.  Also, where are you calling ```actionUrl```? I just tested it in a frontend template, and it didn't prepend w/ "admin" on my end.  
  > **username_3**: I believe the `siteMap` in the url needs to be camel-cased... This is a situation where the path isn't indicating a _directory_, it's indicating a _plugin class_ for the action routing to follow.  
  > **username_3**: Nevermind, I see "Sitemap" in your controller name is all lowercase.  
  > **username_0**: You were right - I was using a url returned from actionUrl within the admin, and forgot to remove the admin segment. Works superduper now.  
  
  ---
  
  