1

Is there a way to ignore part of a querystring if it contains the parameter "action"?

We have a 3rd party site which returns to one of our sites and they append "&action=something" to the querystring. The 3rd party site are not able to remove this parameter, so when the user gets returned to our site they're greeted with a 404 page - the Craft docs suggest 'action' is used to determin an action controller to use, which in this case there is not one set.

My 'hack' of an idea would be to detect the parameter in a template, remove that parameter, then go to the url without the 'action' parameter set. This would add more page requests, which would be annoying for a user I can imagine.

2

I think we need more information to be able to consider possible solutions. I personally wouldn't do anything in Craft, rewriting this URL before it hits the application would be cleaner. I don't know if it's possible to configure the 'action' parameter name in Craft so let's assume not.

Are the referring URLs always the same? In other words, is the visitor always returned to the same URL on your site (which contains &action=something)? If so, a fairly simple Apache/nginx rewrite URL could be written to remove the parameter from the request.

If not, it may still be achievable with a rewrite rule if you're willing to trust the HTTP_REFERER variable.

2
  • Just to confirm, the action parameter is indeed hardcoded, so it's impossible to change it. See craft\web\Request
    – MoritzLost
    Apr 20 at 13:43
  • We've gone for a URL rewrite using Apache, it seems to work so far in testing and you're right in it should be a cleaner way. My 'hack' was a last resort, if it were even possible.
    – Jaytrix
    Apr 21 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.