My site is multilingual and if a user requests a page without specifying the two-letter language code, he'll be redirected to the proper language (using IP or previous cookie settings). For example you can try going to http://colnect.com and see you'll be redirected to colnect.com/en or colnect.com/es or other (53 languages are supported).
The PROBLEM is when I get bogus requests (mostly from bots) such as colnect.com/fdlghsweru my redirection code first redirects it (code 302) to colnect.com/en/fdlghsweru which will then return 404. This means: * There are two requests instead of one -> more server load * Some bots will either try colnect.com/fdlghsweru again later or even believe it exists
The code I've done is currently located in MyUser::setCulture()
Is there a good place where I can locate the code only when I know an action is about to get executed and not get 404?
UPDATE: what I currently do is check in my code if $sfRequest->getParameter('module') is one of the valid modules in my application. This covers most bogus requests but not the one created by malfunctioning bots which append bogus parameters to existing URLs.
Thanks