<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>

CC BY-SA 3.0
2015-03-31T12:23:06.037Z
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.
Fred Carlsen
CC BY-SA 3.0
2015-03-31T12:50:19.910Z
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.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-03-31T16:19:16.540Z
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.
Lindsey D
CC BY-SA 3.0
2015-03-31T16:20:59.700Z
Nevermind, I see "Sitemap" in your controller name is all lowercase.
Lindsey D
CC BY-SA 3.0
2015-04-01T20:23:31.747Z
You were right - I was using a url returned from actionUrl within the admin, and forgot to remove the admin segment. Works superduper now.
Fred Carlsen
CC BY-SA 3.0
2015-03-31T12:21:01.050Z
2015-03-31T13:22:07.150Z
2015-03-31T13:22:07.150Z
Aaron Berkowitz
<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>

CC BY-SA 3.0
2015-03-31T11:23:50.593Z
What does your route look like?
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-03-31T11:25:34.163Z
No routes setup for this plugin. Trying to access it through the action url, like so: /index.php/admin/actions/sitemap/xml
Fred Carlsen
CC BY-SA 3.0
2015-03-31T11:33:53.840Z
Beats me. Your code looks legit. What happens if you remove everything inside ```actionXml()``` and just ```die( 'something' )```?
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-03-31T11:41:47.083Z
Still redirects.
Fred Carlsen
<controller>
Anonymous access to controller action fails
# 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.  

---

