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?

  • What does your route look like? Mar 31, 2015 at 11:23
  • No routes setup for this plugin. Trying to access it through the action url, like so: /index.php/admin/actions/sitemap/xml Mar 31, 2015 at 11:25
  • Beats me. Your code looks legit. What happens if you remove everything inside actionXml() and just die( 'something' )? Mar 31, 2015 at 11:33
  • Still redirects. Mar 31, 2015 at 11:41

1 Answer 1


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

  • 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. Mar 31, 2015 at 12:23
  • 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. Mar 31, 2015 at 12:50
  • 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
    Mar 31, 2015 at 16:19
  • Nevermind, I see "Sitemap" in your controller name is all lowercase.
    – Lindsey D
    Mar 31, 2015 at 16:20
  • You were right - I was using a url returned from actionUrl within the admin, and forgot to remove the admin segment. Works superduper now. Apr 1, 2015 at 20: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.