Controller action redirection when called via route I have a route set up in routes.php that calls a controller action using something similar to what is described here: https://straightupcraft.com/articles/how-do-i-setup-a-route-to-point-to-a-controller-action-instead-of-a-template

This works much better for my purposes than POSTing a form to the controller. However, I'm not sure how best to handle redirects. Ideally I would like to redirect back to the page where the user clicked on the link, but calling

$this-&gt;redirectToPostedUrl()


doesn't work when using a route like this. The URL just remains the URL as defined in the route.

Is there a different method I can use to make sure users are returned to the page where they were when they clicked the link?
You're mistaken about how redirectToPostedUrl works... That's designed to redirect from a form submission, when the redirect field was supplied:

&lt;input type="hidden" name="redirect" value="page/to/redirect/to"&gt; 


What you really want is this:

$this-&gt;redirect(craft()-&gt;request-&gt;getUrlReferrer());


The request-&gt;getUrlReferrer method will actually retrieve the originating page URL.