TransWikia.com

Ignore 'action' querystring parameter

Craft CMS Asked by Jaytrix on May 9, 2021

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.

One Answer

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.

Correct answer by Andy on May 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP